How to Configure Network Static IP Address in Ubuntu 18.04

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

16 Responses

  1. Joel Pearson says:

    I think you have a mistake with regards to what “netplan generate” does, you have a notice saying “Important: In case a YAML file is not created by the distribution installer, you can generate the required configuration for the renderers with this command.”, this is incorrect. On the man page (http://manpages.ubuntu.com/manpages/cosmic/man8/netplan-generate.8.html) it says “netplan-generate – generate backend configuration from netplan YAML files”

    “netplan generate” *reads* the YAML files it can’t create the yaml file for you, ie it won’t touch any of the yaml files in the “/etc/netplan/” directory.

    I have noticed when I run “netplan generate” it creates the configuration files in “/run/systemd/network/” on Ubuntu 18.04

    The man page also says: “You will not normally need to run this directly as it is run by netplan apply, netplan try, or at boot.”

    So I think you should remove the reference to “netplan generate” as it’s just a red herring. If there is nothing in “/etc/netplan” then that command isn’t going to help you out.

  2. Zoran Jovanic says:

    Those linux devs who made this decision are absolutely bunch of very strong and bad words. You have no idea what did you do to a mindset of administrator who expect that nobody, really nobody mess with sys admin networking stuff.

    Specially developers. Do you have ANY idea what did you just do by switching to this netplan? This is unbelievable stupid. Unbelievable. Sys Admin really have other things to do besides watching which developer had some stupid inspiration and decide to change stable thing that work flawlessly.

    Unbelievable. Have no nice word for this move. You should really go and destroy your head with hammer.

  3. johan says:

    Interesting tutorial but at the netplan part you are going to fast for me. I don’t have that file, i do have a 50cloudminitmyaml does this mean i need to add my ipaddress in the 5-cloud file?

  4. Jasper Frumau says:

    After adding ens7 to

    network
         version:  2
         rendereder: networkd
         ethernets:
              ens3:
                   dhcp4: yes
                   dhcp6: yes 
              ens7:
                   dhcp4: no
                   dhcp6: no
                   addresses:
                   - 10.0.0.2/8
                   gateway4: 10.0.0.1
    

    and checking with:

    $ sudo netplan apply --debug
    

    all seemed well, but I can no longer ssh into my box now. Why?

    • Pabs says:

      Can you try this >>

      # telnet yournewipaddress 22
      

      that should tell you if open or available, also change the yes and no to true and false.

  5. Troy Starkey says:

    How is it, that in 2018 the configuration of your networks is decades behind Redhat 6?? Since when have we been reduced to config file editing, when the old classic blue and red config menu’s were fantastic. I dunno, even Raspberry Pi has better tools out of the box…..

  6. Ton Lagerway says:

    Hi,

    Looking to set up a static IP address in preparation for setting up a personal VPN via raspberry Pi

    Cannot find not generate a netplan file at all

    Configuration of ethernet looks as follows:

    [email protected]:~$ ifconfig -a
    enp3s0f1: flags=4163  mtu 1500
            inet 192.168.1.102  netmask 255.255.255.0  broadcast 192.168.1.255
            inet6 fd80:1382:3798:a000:6868:a0df:eda4:255f  prefixlen 64  scopeid 0x0
            inet6 fe80::8947:42e1:8a88:66c9  prefixlen 64  scopeid 0x20
            inet6 fd80:1382:3798:a000:2dfb:4728:37a3:42a9  prefixlen 64  scopeid 0x0
            ether 88:d7:f6:2f:a1:2b  txqueuelen 1000  (Ethernet)
            RX packets 593  bytes 359039 (359.0 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 642  bytes 87846 (87.8 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 298  bytes 22474 (22.4 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 298  bytes 22474 (22.4 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    wlp2s0: flags=4098  mtu 1500
            ether dc:53:60:f0:13:3d  txqueuelen 1000  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    

    Just a “Rank-Pensioner” amateur who can copy & past but does not understand much about Linux!

    Cheers,
    Ton

    • Aaron Kili says:

      @Ton

      If there is no default netplan config file, try to generate one as shown in the article, then put your config in there. For more information, read the netplan man page.

  7. Pabs says:

    dhcp4: yes
    dhcp6: yes

    dhcp4: no
    dhcp6: no

    has to be changed to
    dhcp4: true
    dhcp6: true

    dhcp4: false
    dhcp6: false

    • Aaron Kili says:

      @Pabs

      Yes, this is correct but yes or no values also work. After i installed Ubuntu 18.04, one of the default interfaces using dhcp4 had a value of yes(see the screenshot in article).

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.