How to Configure Network Static IP Address in Ubuntu 18.04

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

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...

20 Responses

  1. Dwarakanath S says:

    Hello I’m trying to set up my computer with GPU to be accessed from my laptop and from my friends laptop through putty, for this the solution i thought it would work was set up a static IP and open port 22 so that we can access the GPU machine through putty from other laptop.

    After i set up the static IP my internet connection in Gpu machine is not working also i don’t have an idea how to proceed further in port forwarding .

    1. My questions are is my solution to set up static IP and open port 22 will work for my above requirement.
    2. Any suggestions to solve my internet connectivity issue.

    • Ravi Saive says:


      First check your static IP is reachable from other laptop by doing a ping request to IP.
      Secondly, make sure the opened port 22 is listening on the system using netstat command.

      • Dwarakanath s says:

        @Ravi save thanks for replying ping from my laptop to connect my static ip machine gets timeout, I see that you ask me to check the port 22 is listening using netstat to make it more clear I am yet to open port 22 for which any help will be highly appreciated

        • Ravi Saive says:


          Your static IP must be reachable from your laptop, and to open port 22 on ufw firewall, run:

          $ sudo ufw allow 22
  2. 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 ( 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.

  3. 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.

  4. 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?

  5. Jasper Frumau says:

    After adding ens7 to

         version:  2
         rendereder: networkd
                   dhcp4: yes
                   dhcp6: yes 
                   dhcp4: no
                   dhcp6: no

    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.

  6. 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…..

  7. Ton Lagerway says:


    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  netmask  broadcast
            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  netmask
            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!


    • Aaron Kili says:


      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.

  8. 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:


      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).

Leave a Reply to Aaron Kili Cancel reply

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.