8

I've tried to find a way to configure a new connection manageable by NetworkManager using a terminal/shell script all day long, but I've been unsuccessful.

The reason is that I have a lot of openvpn configuration files and I wanted to have a nice and fast way of importing them, also beacuse NetworkManager openvpn plugin doesn't parse the certificates embedded into configuration files, so the only way to configure a new VPN connection is to do that manually via the GUI after I run a script to extract the certificates from the config files, which is a rather long and tedious process.

I found that on RedHat the nmcli utility has the ability to configure a new connection in this way:

nmcli con add [...]

However this is not possibile on (standard) Linux Mint 17.1.

I tried to add a new connection manually, adding a new file in /etc/NetworkManager/system-connections

[connection]
id=VPNConnection
id=3389cf54-949e-4c69-a746-864f0f8720b8
type=vpn

[vpn]
service-type=org.freedesktop.NetworkManager.openvpn
fragment-size=1300
connection-type=password-tls
password-flags=1
auth=MD5
tunnel-mtu=1500
cipher=AES-256-CBC
comp-lzo=yes
cert-pass-flags=0
remote=[vpn provider]
port=[vpn port]
mssfix=yes
username=[username]
remote-cert-tls=server
cert=[user cert]
ca=[ca cert]
key=[user priv. key]

[ipv6]
method=ignore

[ipv4]
method=auto

but this new configuration doesn't show up in NetworkManager.

Also, I don't have any ~/.gconf/system directory, neither under my personal home nor under /root.

Where could NetworkManager read configuration files from?

1
  • I have the very same issue -- have you been able to find a solution in the meantime? Thanks! (I believe that one option is to get the experimental package of NM 1.0 but I don't want to mess with my system that way.) May 30, 2015 at 10:12

3 Answers 3

8

Check your /etc/NetworkManager/NetworkManager.conf

Under [main] there should be a plugins directive and if you have enabled the keyfile plugin (i.e. plugins=keyfile,ifupdown or similar), it should monitor the /etc/NetworkManager/system-connections/ directory for file changes.

Further, a man NetworkManager.conf tells you that 'it will ignore files that are readable or writeable by any user or group other than root'.

Don't know if this solves your problem, but it is worth checking out!

According to this, it should work with NetworkManager v7+

Cheers! / Daniel

1

This worked for me:

nmcli reload "your connection name"

followed by a reboot. Reactivation will probably work as well.

2
  • 2
    I am having the exact same problem. But the reload command is not included in my version of NetworkManager (most current package for Raspbian Wheezy). Any other idea? Rebooting and restarting the service didn't help either. May 30, 2015 at 10:12
  • 2
    I think nmcli connection reload "your connection name" is the correct one. Nov 8, 2017 at 9:54
0

Running reload command without connection name works just fine - connection name, which is defined by variable id= within script itself, can be different than filenane.

nmcli connection reload 

will reload all connections from /etc/NetworkManager/system-connections/.

also three things that must be done:

chmod 600 /etc/NetworkManager/system-connections/*
chown root:root /etc/NetworkManager/system-connections/*

and script itself must be valid :)

To try if it's working fine you may generate with easy script for static IPv4 address and disabled IPv6 with such script:

#default first network interface is ens192
interface=ens192
#IPv4
ipv4=10.151.62.83
#mask in one or two-digits format - for local networks 8 to 32
maskv4=24
#ipv4 gateway address
gateway=10.151.62.254
#dns
dns="10.0.0.1;10.0.0.2"
#domain which will be used to search hosts, can be more than one 
domain="example.com;example.net"

echo -e "[connection]\nid=$interface\nuuid=$(uuidgen -t)\ntype=ethernet\nautoconnect-pririty=-999\ninterface-name=$interface\n\n[ethernet]\n\n[ipv4]\naddress1=$ipv4/$maskv4,$gateway\ndns=$dns\ndns-search=$domain;\nmay-fail=false\nmethod=manual\n\n[ipv6]\nignore-auto-dns=true\nignore-auto-routes=true\nmethod=disabled\nnever-default=true\n\n[proxy]" > /etc/NetworkManager/system-connections/$interface.nmconnection

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .