How to configure static IP address on Ubuntu 18.04 Bionic Beaver Linux -

Depending on your Ubuntu installation Netplan may not be avaiable on upgraded Ubuntu systems. If this is your case you might attempt to configure a static IP address for your network interface using /etc/network/interfaces file as described at the end of this document.

This is a companion discussion topic for the original entry at


Excellent post, although you do not explain why in 18.04 you can only use a static interface. For example, if in /etc/network/interfaces there are two network interfaces (eno1, eno2) and both have static IP, only the second will work. For both to work the first must be in dhcp and the second static. This did not happen at 16.04 LTS. See

Jason A. Quest

Irregular code indenting breaks netplan? What is this, fucking Fortran?


That’s wrong: Configure static IP address using interfaces file

Ubuntu Bionic 18.04 uses netplan, your advice will potentially just break stuff. It certainly won’t be there after a reboot. There is no need to do work arounds. Just google ubuntu 18.04 netplan static IP.

I don’t use the gui, but that might be OK.

Server (headerless) uses : netplan/networkd
Desktop (gui) uses: netplan/networkmanager

So the advice you are giving is (for headerless at least) is making things worse. This is why people struggle with Ubuntu, too many people giving bad advice.

Lubos Rendek Mod -> Stephen

Thank you for the input!!!

That’s wrong: Configure static IP address using interfaces file
Not entirely. Upgraded system may/need still to use interfaces file. In any case the article is not updated. thank you

A huge problem with almost all Linux related hints is the need for someone to have read everything up to yesterday or you’re screwed. In this relatively simple example, how does one know what the ethernet interface is magically named? For that matter , there seem to be several different .yaml (whatever that is) file names used. How does one know which is which?

Maybe I’m just dumb or too old school, but going from 16.04 to 18.04 introduces all kinds of bright new ideas (worthy of Microsoft) that are never explained.

My issue becomes: “sudo netplan try” yields an error that netplan expected a “mapping” line. WTF?

FWIW, I found the command line info for netplan very helpful. Thanks!

When I try to use the GUI as a regular user (to set the static ip), the “wired” option never appears. But the command line worked fine.

I followed the instructions in this post for setting a static IP address by updating the 01-network-manager-all.yaml file /etc/netplan. After hitting “apply” I lost connectivity to the server altogether. I was able to get a colleague with direct access to the workstation to reverse the changes I made.

I entered the line items as detailed in the post, substituting the IP addresses and the interface which was “eno1” in this case.

Further, in the example post, what is the meaning of the number 4 in “dhcp4” and “gateway4”? Since the workstation only has the single interface eno1, I entered “dhcp1” and “gateway1” but it failed to apply. After substituting with “dhcp4” and “gateway4”, the apply was successful but then it broke connectivity.

What happened?

Hi Suzan,

That is to be expected. Changing IP address while using it as a existing established remote connection is not a good idea and could not end differently.

In relates to IPv4 ( Internet Protocol version 4 ) . Meaning you have two options.

  1. dhcp4 ( IPv4 )
  2. dhcp6 ( IPv6 )

Same goes for the gateway4 statement.

Hope this helps…


Thanks for your feedback, Lubos.

Regarding the IP address, I did not change it. The workstation had already been setup with a static IP address via the GUI and I configured the netplan config file using the same IP address, mask and remote gateway as were already configured. My goal was to set new DNS server ip addresses and make the change take affect by restarting the networking. (I don’t have access to the GUI, only SSH).

I asked a remote colleague to delete the netplan config file and restart the workstation. I think they reconfigured the IP addresses via the GUI, so now I have access to the workstation again, although mysteriously, now DNS is no longer working.

Are DNS IP addresses are configured in a different config file on Ubuntu 18 via command line?


Have you tried to specify the required DNS server within the /etc/resolv.conf file? For example to have a server to resolve your DNS queries you could add the following line into your /etc/resolv.conf configuration file:


No need for service or server restart. Test your DNS server with the dig command. Example:


; <<>> DiG 9.10.3-P4-Debian <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14781
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 512
;               IN      A

;; ANSWER SECTION:        299     IN      A        299     IN      A

;; Query time: 348 msec
;; WHEN: Thu Aug 15 18:45:32 CEST 2019
;; MSG SIZE  rcvd: 76

Note the SERVER: from the above output. You will need root privileges to edit the /etc/reslov.conf file. Also be aware that the order in which you declare DNS servers matters.

Hope this helps


Thanks very much, Lubos, that worked.

I was under the impression that resolv.conf was updated by another process and was not meant to be updated manually.

Thanks again,


Well you are right. It will be updated in case your host is set with dynamic IP address. Hence, if you receive a network settings information from the DHCP, the resolv.conf file will be updated with an appropriate DNS server. Not sure what your exact environment settings are but from the information you provided, you should be on the safe side.