Cannot connect two VM's via an openvpn service

This forum is for general conversation and user-user networking.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
WobblyWes
OpenVpn Newbie
Posts: 5
Joined: Thu Aug 27, 2020 3:47 pm

Cannot connect two VM's via an openvpn service

Post by WobblyWes » Thu Aug 27, 2020 4:14 pm

To the dear good people at openvpn, i am very new to this. I have been struggling for days to get a connection working between two Ubuntu VM's, one a server, the other a client. I keep getting a network unreachable error. Running sudo openvpn client.conf just hangs. However the server appears to be up and running ok (active, tun shows up in ip a). I would post the logs, however am unable to get them out of the VM at this point.
I was wondering whether someone could look over my conf files, perhaps they will spot an error.



Error from client log:
write UDP - Network is unreachable (code101)
Error from server log
Socket bind failed on local address [AF inet] undef:1194 Address already in use (errno:98)


Any help much appreciated.

The client conf file has undergone numerous changes and the two lines key-direction 1 and remote-cert-tls server are the most recent experimental additions.

Client.conf

client
dev tun
proto udp
port 1194

remote 10.10.10.1

resolv-retry infinite

persist-key
persist-tun

ca <path>
cert <path>
key <path>

key-direction 1
cipher AES-256-CBC
auth SHA512
auth-nocache

user nobody
group nogroup
compress lz4
log <path>
status <path>
verb 4

remote-cert-tls server




Server Config

port 1194
proto udp
dev tun

ca <path>
cert <path>
key <path>

dh <path>
crl-verify <path>

server 10.10.10.0 255.255.255.0
push "redirect-gateway def1"

duplicate-cn

cipher AES-256-CBC
tls-version-min 1.2
tls-cipher TLS-etc>>>
auth SHA512
auth-nocache

keepalive 20 60
persist-key
persist-tun
compress lz4
daemon
user nobody
group nogroup

log-append <path>
verb 3

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: Cannot connect two VM's via an openvpn service

Post by TinCanTech » Thu Aug 27, 2020 5:05 pm

First, you have to prove that your VMs can even see each other..

WobblyWes
OpenVpn Newbie
Posts: 5
Joined: Thu Aug 27, 2020 3:47 pm

Re: Cannot connect two VM's via an openvpn service

Post by WobblyWes » Thu Aug 27, 2020 5:11 pm

They are on a virtual interface, and can successfully ping each other.

Port forwarding is on for both devices:
net.ipv4.ip_forward=1
and on;
sudo sysctl -p

Tried with firewall disabled and with iptables rule to accept and forward any udp traffic on :1194

Both services are active(running)

The client service is stuck at pre-initialisation.

I cannot get a tun device on the client however as i understand it, it will only appear on successful connection.

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: Cannot connect two VM's via an openvpn service

Post by TinCanTech » Thu Aug 27, 2020 6:24 pm


WobblyWes
OpenVpn Newbie
Posts: 5
Joined: Thu Aug 27, 2020 3:47 pm

Re: Cannot connect two VM's via an openvpn service

Post by WobblyWes » Thu Aug 27, 2020 6:55 pm

I have been stuck on this for 3 days pulling my face out, and i have just changed the line in client.conf:

remote 10.10.10.1
to the address of the virtual NIC:
remote 192.168.30.1

and now i can ping 10.10.10.1

So i have simply misunderstood the requirement of

client.conf:
remote:<ip>

Believing that it should be the ip that i assigned to the ovpn server?

Does this sound correct.

Regards.

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: Cannot connect two VM's via an openvpn service

Post by TinCanTech » Thu Aug 27, 2020 7:05 pm

WobblyWes wrote:
Thu Aug 27, 2020 6:55 pm
Does this sound correct
No .. it sounds like you do not understand which IPs are actually assigned to your VMs because you do not yet understand how your VM software works, especially the bit about networking.

WobblyWes
OpenVpn Newbie
Posts: 5
Joined: Thu Aug 27, 2020 3:47 pm

Re: Cannot connect two VM's via an openvpn service

Post by WobblyWes » Thu Aug 27, 2020 7:09 pm

My virtual machines are both using the same isolated network.

ClientVM@192.168.30.2
ServerVM@192.168.30.1

The openVpn server sits on the 10.10.10.0/24 network.

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: Cannot connect two VM's via an openvpn service

Post by TinCanTech » Thu Aug 27, 2020 10:20 pm

WobblyWes wrote:
Thu Aug 27, 2020 6:55 pm
I have been stuck on this for 3 days pulling my face out, and i have just changed the line in client.conf:

remote 10.10.10.1
to the address of the virtual NIC:
remote 192.168.30.1

and now i can ping 10.10.10.1

So i have simply misunderstood the requirement of

client.conf:
remote:<ip>

Believing that it should be the ip that i assigned to the ovpn server?

Does this sound correct.

Regards.
VirtualBox NAT ..

@Mod Nothing to do with OpenVPN and no logs provided.

WobblyWes
OpenVpn Newbie
Posts: 5
Joined: Thu Aug 27, 2020 3:47 pm

Re: Cannot connect two VM's via an openvpn service

Post by WobblyWes » Fri Aug 28, 2020 6:42 am

No not virtual box nat, it has everything to do with openvpn;

Client.conf
Remote <server ip>

Is it the ip value set in server conf?
Ie 10.10.10.1 in my case..

Or should it be the local private address of the virtual device. Thats the question, simply what value should be placed in remote <ip> in the client.conf.

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: Cannot connect two VM's via an openvpn service

Post by TinCanTech » Fri Aug 28, 2020 11:55 am

OpenVPN will try to connect to what-ever IP you tell it to.

If you give it the wrong IP then it will obviously fail.

Post Reply