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

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 https://linuxconfig.org/how-to-configure-static-ip-address-on-ubuntu-18-04-bionic-beaver-linux

Maravento

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 https://unix.stackexchange.com/questions/446039/problem-with-interface-with-ip-static-in-ubuntu-18-04

Jason A. Quest

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

Stephen

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…

Lubos

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?

Suzan

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

nameserver 8.8.8.8

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

$dig linuxconfig.org

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

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;linuxconfig.org.               IN      A

;; ANSWER SECTION:
linuxconfig.org.        299     IN      A       104.24.10.18
linuxconfig.org.        299     IN      A       104.24.11.18

;; Query time: 348 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Aug 15 18:45:32 CEST 2019
;; MSG SIZE  rcvd: 76

Note the SERVER: 8.8.8.8#53(8.8.8.8) 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

Lubos

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,

Suzan

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.

This is really crap, how hard is it to configure a fucking IP address?

1 Like

when they let children trying to fix what is not broken
the world is Kubernetes and docker and yaml files lets screw the networking just to be cool

1 Like