I recently managed to break the network on my VM that hosts this blog. Basically I removed the NetworkManager-initscripts-ifcfg-rh package because I don’t use the old style ifcfg configuration anywhere else and I had forgotten how long I’d had this VM. So I went into the web console, manually bought up the network with ip commands and reinstalled the package but it made no difference. Oh well! Time to just move it to the new config so I just worked out the nmcli options for all the bits in the old ifcfg. This VM network is nothing special, it’s basically dual IPv4/IPv6 interface with associated DNS.
Step 1: Show existing connections:
$ sudo nmcli c NAME UUID TYPE DEVICE eth0 a603bba7-fad8-3c71-9d4c-2cd5dc50e114 ethernet eth0
Step 2: Delete existing connection:
$ sudo nmcli c del a603bba7-fad8-3c71-9d4c-2cd5dc50e114
Step 3: Create a new connection (Note the IP addresses are random, the DNS servers are the Google public ones):
$ sudo nmcli c add type ethernet ifname eth0 con-name eth0 mac 80:00:00:ab:cd:ef ip4 192.168.10.6/24 gw4 192.168.10.1 ip6 fe80::b257:377c:e7b3:29ed/64 gw6 2A03:B0C0:0003:00D0:0000:0000:0000:0001 ipv4.dns "220.127.116.11 18.104.22.168" ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
Now the blog is back! The new connection is stored in /etc/NetworkManager/system-connections/eth0.nmconnection