wireguard 1 client connected to multiple servers - vpn

I am using 2 cloud providers AWS and GCP and using wireguard to connect to them privately with separate tunnels by using windows wireguard client. Currently I have to disconnect connected tunnel in order to connect to another tunnel. My goal is to to connect both cloud providers i.e. aws and gcp simultaneously. I have tried to add both peers in a single tunnel file but after activation it only shows it is connected to 2nd peer.
my windows client tunnel file is given below.
[Interface]
PrivateKey =
Address = 10.0.0.x/x
DNS = 8.8.8.8, 8.8.4.4
[Peer]
PublicKey =
AllowedIPs = 172.31.x.x/x
Endpoint = 54.x.x.x:51820
[Peer]
PublicKey =
AllowedIPs = 10.128.x.x/x
Endpoint = 34.x.x.x:51820

Seeing you said you are using the Windows WireGuard client here is what you are looking for
Create registry key
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Wireguard\MultipleSimultaneousTunnels
DWORD (32-bit) Value: 1
https://rair.dev/wireguard-windows-multiple-simultaneous-tunnels/

You will have to change your network topology as to make those two cloud hosts a Wireguard peer that makes persistent connections to your Wireguard server.
Of course, that won’t work if your newly-minted server is behind a NAT.
If stuck with NAT, My suggestion would be to make one of your cloud the server and your home host and other cloud the peers.
A better way is to use two separate Wireguard interfaces at your home host and make them both a persistent peers.

Related

Can ssh to GCP Private instance but cant access application interface through cloud shell

Here is what i have:
GCP instance without external IP (on VPC, and NAT), and it accepts HTTP HTTPS requests
firewall allows ingress TCP for 0.0.0.0 and also for IAP's IP 35.235.240.0/20 on all ports for all instances
I ssh to the instance via IAP and run the application in the terminal on port 5000 and 0.0.0.0 host and leave the terminal hanging, but when I connect in parallel through cloud shell and ssh to this instance through IAP, and then click on web preview on port 5000, I get "Couldn't connect to a server on port 5000".
I have said that it could be a firewall rule blocking IAP, so that's why I gave access to all ports for IAP (for testing)
P.S: the process has been done on a VM with external IP and it got validated ( but without the need to connect to cloud shell to do web preview, I checked the UI with IP:port in the browser )
What did I miss?
You may be following the guide on Building Internet Connectivity for private VMs and this part on Configuring IAP tunnels for interacting with instances and the use of TCP Forwarding in IAP. By Tunneling other TCP connections:
"The local port tunnels data traffic from the local machine to the remote machine in an HTTPS stream. IAP then receives the data, applies access controls, and forwards the unwrapped data to the remote port."
You can create an encrypted tunnel to a port of the VM instance by:
gcloud compute start-iap-tunnel INSTANCE_NAME INSTANCE_PORT \
--local-host-port=localhost:LOCAL_PORT \
--zone=ZONE
I guess you want to use INSTACE_PORT and LOCAL_PORT the same, 5000.
Be aware of it's known limitations.

How to connect Compute Engine Instance to Private VPN

I'm trying to use nmcli to configure a VPN in a remote machine.
The issue is that networking interfaces are google managed.
I've created a VPN connection with
sudo nmcli connection add type vpn vpn-type openvpn ifname test-vpn vpn.data "ca = /home/myuser/ca.vpn.cer, connection-type = password, password-flags = 2, port = 443, proto-tcp = yes, remote = vpn.mycompany.com, username = myuser#company.com"
But when I try echo "vpn.secrets.password:mypass" > pass.txt; sudo nmcli connection up vpn-mangel-vpnt passwd-file pass.txt it raise Error: Connection activation failed: Could not find source connection.
I've tried to change /etc/NetworkManager/NetworkManager.conf to set ifupdown manage to true:
And adding those lines in /etc/network/interfaces
With that, the VPN connects (Wrong pass fails) but the VPN is not connected to machine network
After many attemps and error, deleting new interfaces that are dynamically created I finally got the vpn connected, and removing folders from run/interfaces I successfully connected to vpn and could check it with a ping. Some minutes later o lost the ssh connection.
I've restarted the machine, but if I connect to the VPN lose the ssh connection.
And I can't replicate in a new instance.
I don't have much idea about VPNs and Interfaces so could someone guide me in what look for?
Google Cloud Virtual Private Cloud (VPC) networks are by default isolated private networking domains. Networks have a global scope and contain regional subnets. VM instances within a VPC network can communicate among themselves using internal IP addresses as long as firewall rules permit. However, no internal IP address communication is allowed between networks, unless you set up mechanisms such as VPC Network Peering or Cloud VPN.

How to connect to on-premise OpenVPN server from OCI (Oracle Cloud Infrastructure) Compute instance?

My company has an on-premise network which is opened by OpenVPN server.
In the ordinary scenarios, I used to connect to that server very easily.
However, when I tried to that server from the OCI compute instance which I connected by SSH from my laptop, there exist some problems. As soon as I try to connect VPN server, my SSH connection is closed.
IMHO, this may occurred because VPN connection changes network information and so my SSH connection might be lost.
I tried to look around to find out how to connect to VPN from OCI, but almost everything was using IPSec protocol which Oracle provided, others were about builting OpenVPN Server on the OCI instance.
I'm very novice for the network structure. So, please give me some hint to resolve this problem.
Thanks,
I get the following:
You have Ubuntu 18.04 VM on a Public Subnet in OCI
You have OpenVPN Server running on On-Prem.
You would like to access your On-Prem from Ubuntu VM on OCI.
If I understood it correctly, the best way is to set up IPSec VPN. It isn't that hard if you hit right steps. At the high level, you will be doing the following steps. I have used IKEv1 in my attempts in the past.
OCI:
Create a DRG
Attach/Associate it to your VCN
Create a CPE (Customer Premise Equipment) and mark the IP Address of OpenVPN server to it.
Create an IPSec Connection on the DRG. It will create two Tunnels with its own Security Information.
Set up Routing on associated subnet (i.e., one that hosts Ubuntu VM) so traffic associated to On-Prem CIDR are routed to DRG.
On-Prem:
Create necessary configuration to create the Tunnels upto OCI (Using the configuration information from previous steps such as VPN Server IP Addresses and Shared Secrets)
Set up Routing so that the Traffic destined for OCI CIDR ranges are sent to associated Tunnel Interface
This ensures that you can create multiple VMs on the OCI Subnet all of which can connect to your On-Prem infrastructure. OCI Documentation has sufficient information in setting up this VPN Connection.
Alternatively if your only requirement is to establish connectivity between Ubuntu VM on OCI to OpenVPN server On-Prem, you might use any VPN Client software and set it up. This doesn't need any of the configuration steps mentioned above.
Worker nodes in private subnets have private IP addresses only (they do not have public IP addresses). They can only be accessed by other resources inside the VCN. Oracle recommends using bastion hosts to control external access (such as SSH) to worker nodes in private subnets. You can learn more on using SSH to connect through a bastion host here - https://docs.cloud.oracle.com/en-us/iaas/Content/Resources/Assets/whitepapers/bastion-hosts.pdf

VPN server and client (possibly) on the same machine

What I'm trying to achieve is:
Connect to a VPN as client and route all my internal network's traffic over the VPN.
Run a VPN server, so that people from outside can connect to my internal network and get routed over the a.m. VPN client.
I'm trying to achieve that with a router running dd-wrt (netgear D6200), and / or a raspberry pi.
Can someone tell me if this can be achieved, and if, direct me to what would be a possible solution?
(I'm not looking for a tutorial, just a direction)
Thanks!
This thread probably does not belong here.
Consider using OpenWRT instead of dd-wrt. OpenWRT gives you a usable build system and easier to customize and build. I am not advocating OpenWRT. This can be a stop gap measure.
You can setup a OpenVPN server and OpenVPN client using the standard
documentation available on OpenWRT Wiki and also OpenVPN site.
Add to OpenVPN server.conf the following directive redirect-gateway def1. This will push the default gateway to clients connecting to OpenVPN server. Further, make sure you are using a unique network IP pool for VPN clients and does not clash with the remove VPN server.
Make sure you are masquerading the VPN traffic (Clients of local VPN server) before forwarding to remove VPN server. This can be tricky as this interface does not exist at boot time. It needs to be configured using up and down scripts
Make sure you are allowing traffic (clients of local VPN Server) on VPN interface to be forwarded in your firewall rules
Before setting up the OpenVPN server, make sure
The remove VPN server is pushing the default gateway to your VPN
client
You have setup the firewall correctly
You are able to reach the cloud through the Remote VPN Server. Checking with some site like www.whatismyip.com will help
Yes this is possible with dd-wrt on Netgear.
There is no need of Raspberry (unless you meant to run the remote VPN server on it).
Configure and run VPN server on dd-wrt - and try connectivity by connecting clients. Both tun/tap should work in general (with VPN client running). I tested with tun.
Configure and run VPN client on dd-wrt and try connecting to your VPN server. By default, the router should start directing all traffic (for its own LAN clients) via the VPN server.
So far so good.
The problem comes when you want dd-wrt's VPN clients (and not just LAN clients) to take the same route. With a VPN client running on dd-wrt, dd-wrt's own VPN clients will not be able to connect to the VPN server running on dd-wrt as such. To make it work, see below.
This is only possible via PBR - i.e. you run VPN client on dd-wrt, but take the router itself off this client, and route only specific clients through this VPN client running on dd-wrt.
With some tweaks using subnet masks, it is possible to include all your LAN and VPN IPs in the PBR policy so that everything (except the router itself) routes through the remote VPN server.
The key is to include dd-wrt's VPN clients' virtual IPs in the PBR. While configuring VPN server on dd-wrt, there is a field for specifying the clients' network and netmask.
If you use this network IP and netmask in client process's PBR policy, your (dd-wrt's) VPN clients will be able to connect to the VPN server running on dd-wrt, and will in turn be routed through the remote VPN server to which dd-wrt is connected as a client.

Why use (open)VPN with (free)radius and not directly with (open)ldap

For a school project I need to setup a SSO solution.
This includes a vpn service, a postgresql DB and LDAP.
For the VPN solution I need to use OpenVPN but why would I use
Radius (as the documentation/assignment states) when OpenVPN has
a perfectly capable (for as far as I can see) implementation for
OpenLDAP.
So why would I set it up that OpenVPN uses freeRADIUS to ask OpenLDAP
for authentication/authorization?
The network setup:
Router (eth0 = outside, eth1 = DMZ, eth2 = proxy, tun0 = openvpn = own subnet)
DMZ (webserver for everything coming from the outside, NGINX and wildlfy)
Proxy (NGINX, bit redundent i know, eth0 = router, eth1 = internal servers)
DB server (eth0 = proxy, runs postgresql)
auth server (eth0 = proxy, runs OpenLDAP)
snmp server (eth0 = proxy, openNMS, just an added bonus not of interest to the assignment really)
Thank you in advance!
I'm not a Open VPN expert, but if you want only to check the users credentials and groups privileges you can bypass RADIUS (but I found it and advanced step not only for the auth, also for future use like wifi 802.1X access etc...)

Resources