0

I have a configured OpenVPN connection which works fine when connecting from command line

openvpn --config myconfig.conf

Now, I'd like to establish this OpenVPN connection automatically when connecting through a certain WiFi network. Network Manager provides this option but of course requires that the OpenVPN connection is configured through Network Manager.

It works fine. Local connections to the network bridged with the VPN are available, even IPv6 works. However, Network Manager does not set the appropriate gateway which means I cannot reach the Internet over IPv4 through this OpenVPN server.

In paritcular, when I connect using the command line,

nmcli device show tap0

returns

IP4.ADDRESS[1]:                         192.168.1.100/24
IP4.GATEWAY:                            192.168.1.1

but when I connect using the Network Manager GUI, it returns

IP4.ADDRESS[1]:                         192.168.1.100/24
IP4.GATEWAY:                            0.0.0.0

Why does that happen? How can I fix it? My config does not contain the gateway address explicitly.

client
dev tap
resolv-retry infinite
nobind
persist-key
persist-tun
comp-lzo
keepalive 1 7

remote 1.1.1.1 1194 udp

redirect-gateway

ca ca.crt
cert cert.crt
key key.key
remote-cert-tls server
tls-auth ta.key 1
1

You can modify the gateway for network manager connections from the command line. So while I cannot find this option in the GUI, you can list the connections

nmcli con show

find yours

NAME                     UUID                                  TYPE             DEVICE 
thenameyougaveit         some-id-ksadbf019-aksb821           vpn              wlan1  

change the address (it will be discarded afaict but you cannot change the gateway address without setting it)

nmcli con mod some-id-ksadbf019-aksb821 ipv4.addresses 192.168.1.113/24

and then set the desired ip4 gateway

nmcli con mod some-id-ksadbf019-aksb821 ipv4.gateway 192.168.1.1

And now it works from the GUI. Of course, if anything changes on the other end, it will stop working.

  • Thank you! Just a quick note: I'm on Kubuntu 17.10, and I didn't have to add an ipv4.addresses for my OpenVPN tunnel (name "tun0"). I applied the gateway to tun0 instead of the NM connection name. – Vanessa Deagan Sep 7 '17 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.