Linux – How to connect to VPN from the command line in Linux

linuxnetworkmanageropenvpn

I have different tunnels that I configured using the network manager GUI.

When I login to my desktop, I'm connected to the internet without any tunnels. To connect to a tunnel, I usually click on the network manager tray icon > VPN connections > Some VPN

I need that done automatically on startup, so I need to know how to do that in the cli.

It would also be nice if I could make sure that no application connects to the internet before the connection is tunneled.

Any ideas?

I'm using Ubuntu 12 and openvpn.

Best Answer

You should have nmcli in that version

nmcli con list

That will list connections you have setup. Find the VPN one

nmcli con up uuid <uuid>