14

How to export and migrate NetworkManager settings to new system?

Use cases are:

  • reinstalling a machine
  • moving network configuration from laptop to desktop system (or vice-versa)

All settings should be migrated, that includes:

  • default and custom network connections
  • wifi connections with passwords
  • VLAN configurations
  • VPN configurations (with keys if possible)

I checked on Arch wiki and it there is nothing on migration, so I'm asking you guys and gals here.

10

Each connection configured in NetworkManager is stored in a file in

/etc/NetworkManager/system-connections

Usually, you can copy needed files from a machine to another (by root, of course).

Warning: some configuration file could reference external resources. E.g. in one of my openvpn files I have a line like cert=/home/andcoz/somedir/somefile.crt. You need to copy any referred file.

  • 7
    This answer is incomplete. NetworkManager assigns a UUID to each system connection that appears to be based on the MAC address of the interface. If you change hardware, NetworkManager won't use old system connections because the UUID no longer matches what it expects. – divestoclimb Jul 12 '17 at 13:30
  • I checked directory /etc/NetworkManager/system-connections on my laptop and I only see vpn connections there. But I don't see any wired or wifi settings there. I'll try moving over one vpn connection and report back if this works or not. So if it works this answers 1/4 of the question. Thanks. – valentt Oct 27 '17 at 8:00
  • 2
    @divestoclimb is there some guide that explains how to rename UUID from old system to new one's ? – valentt Oct 27 '17 at 8:01
  • 1
    @divestoclimb is right, these connections won't be picked up if you migrate to new hardware, only for a reinstall on the same hardware this will work. I'd love to know a solution here, just like valentt! – djvdorp Apr 25 '18 at 16:57
  • The UUID is only a random generated identifier. You have to be sure that each connection has a unique identifier (on each machine). – andcoz Apr 30 '18 at 13:08
3

As mentioned by others, Wi-Fi connection files in system-connections directory have the interface MAC address included. This need to match your current setup hence the procedure is:

  1. copy all files from old machine to new machine from/to directory:

    /etc/NetworkManager/system-connections
    
  2. change MAC address entry in each file from old MAC to new MAC. As root:

    cd /etc/NetworkManager/system-connections
    sed -i -e 's/<old mac>/<new mac>/ *
    
  3. Just in case, restart network manager:

    systemctl restart NetworkManager
    

Old mac you may check from any of the files you copied, new mac if unsure you can check with ip link (or from the file that likely got created when you installed your system for the connection you used to copy the files).

Note: above assumes you had a single Wi-Fi interface in both your old an new setup, but the same logic should work with multiple interfaces.

  • What is the line of MAC for VPN conf files? I only see UUID. How can I re-generate new UUID on a new machine? – 32r34wgf3e Aug 1 '18 at 17:48
1

Wireless settings (at least on Fedora) are kept in this directory:

/etc/sysconfig/network-scripts 

There are two files per wifi connection. First file is named ifcfg-YOURSSID contains wifi network settings and keys-YOURSSID contains wireless network password.

Also there is a related question that explains this: Where are NetworkManager's WiFi settings stored?

0

The other posts are right, but there are minor changes to some points.
The answers are kept in

/etc/Networkmanager/system-connections

You can remove the line mac-address or change it via

cd /etc/NetworkManager/system-connections
sed -i -e 's/<old mac>/<new mac>/' *

You can get the new mac adress via

ip a

Depending on the storage where You kept the files, the file rights may be wrong, just set them via:

chmod 0600 *
chown root:root *

Finally restart Network Manager

systemctl restart NetworkManager

Works the same under ubuntu 18.04.

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.