Main / Nmcli
For Ubuntu 18 and on, the old interfaces file and ifconfig commands don't work anymore for network configuration. Now, we have netplan and Network Manager. The GUI (nm-connection-editor) runs Network Manager tools. The command line tool for making permanent edits is called nmcli. While it's a weirdly dark secret to figure out how to make command line changes, this site gives a good explanation: https://www.tecmint.com/nmcli-configure-network-connection/ The interfaces are known as "devices", but that information represents physical ports only. The actual configuration is stored in what's called a "connection". There are nmcli device commands, but the changes are not permanent. To persist, use nmcli connection commands. This is not as straight forward, because the simple traditional interface names are associated with the device, but not the connection. Instead, the connection is referenced by the string name given to it (for example in the GUI). So, often the first critical step is to change the stupid default name like "Wired connection 2" to something more usable. To change the IP address, make it static, and save, use: sudo nmcli con mod <ifname> ipv.addresses 1.2.3.4/24 sudo nmcli con mod <ifname> ipv4.method manual sudo nmcli con up <ifname> To add a route, use: nmcli con mod <ifname> +ipv4.routes "192.168.122.0/24 1.2.3.4" The information is stored in the files by name in /etc/NetworkManager/system-connections/ TroubleshootingUbuntu sometimes loses it's mind and the menu option to Edit Connections from the taskbar network manager menu is grayed out. This is just a GUI problem. You can still run nm-connection-editor to open it up and make the needed changes. |