I'm looking for the correct way of configuring the network with static IP on Ubuntu Desktop 18.04, but from the command line and not the GUI.

Thank you

2 Answers 2


I think this is as close to the "correct way" as you can get.

First you must find out what your interface name is. To do that just run ip address from the Terminal. On my machine it is eno1 which can be found on the first line:

me@pc:~$ ip address
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 90:b1:1c:aa:bb:cc brd ff:ff:ff:ff:ff:ff
    inet brd scope global eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::5cd1:3ee8:c461:6f12/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

Then you just need to edit the file /etc/netplan/01-network-manager-all.yaml and make it look like this for a static IP address assignment:

# Let NetworkManager manage all devices on this system
  version: 2
  renderer: NetworkManager
      renderer: networkd
        name: eno1
      addresses: []
        search: [example.com]
        addresses: []

This tells netplan to use networkd on the interface eno1 instead of NetworkManager.



Edit /etc/systemd/network/*.network


For wifi to work properly below, make sure you replace wlan0 with your exact wifi name.

You can use systemd directly by adding config files to /etc/systemd/network/*.network

Edit: /etc/systemd/network/10-eth0.network



Edit: /etc/systemd/network/20-wlan0.network



I don't use netplan, so I prefer to remove it:

apt purge netplan.io
rm -rf /etc/netplan

Enable systemd-networkd:

systemctl unmask systemd-networkd
systemctl enable systemd-networkd

Set Wifi password and start at boot:

wpa_passphrase Wifi-SSID Sweet-Password >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
systemctl enable  [email protected]

Speed up boot times by refusing to wait for network at boot:

systemctl disable systemd-networkd-wait-online.service


I can see this is old, but I've added a different method here, which doesn't use a layer of abstraction, such as netplan.io or NetworkManager, which probably more closely answers the title of this thread, if not the question.

Personally, I prefer this method because:

  • Every major distro now uses systemd, but few use netplan.
  • it's simple
  • it's easy to troubleshoot
  • can be used with very complex setups, including bridging, bonding, vlans etc
  • can be used to rename devices and change MAC addresses
  • can be used to set different settings based on wireless SSID and other [Match] directives

Seriously, take a look at the Arch wiki page which explains it in excellent detail with examples. Read the whole thing, because there are a few gotchas. https://wiki.archlinux.org/index.php/Systemd-networkd

  • Since netplan is the default CLI way in ubuntu, I go with netplan as the right answer. But this is a very good method in general. Apr 1, 2020 at 15:06

You must log in to answer this question.

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