Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How to assign a permanent static IP address in 18.04

  1. #1
    Join Date
    Dec 2018
    Beans
    4

    Question How to assign a permanent static IP address in 18.04

    I am running an Ubuntu 18.04 server in Hyper-V on Windows 2012 R2. I am familiar with assigning static IPs in Mint 18.3 via the GUI tools, but not using only the CLI. I tried creating a 99_config.yaml file in the netplan directory that contains the following:
    Code:
       network:
           version:   2
           ethernets:
               eth0:
                   dhcp4:   false
                   dhcp6:   false
                   addresses:   [192.168.20.20/24]
                   gateway4:    192.168.20.1
    If I try to include lines for renderer or nameservers, I would get error messages when I ran the netplan apply command. The above does work and sets the IP address. The problem is that it doesn't always work automatically when I reboot and uses DHCP for an address. This messes up my client PCs using the MySQL server on my Ubuntu server.

    What should I be doing to fix this? Thank you.
    Last edited by coffeecat; 4 Weeks Ago at 09:43 AM. Reason: added code tags

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    15,444
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: How to assign a permanent static IP address in 18.04

    indentation and spacing are ABSOLUTELY critical. Check those. When you post here, use "code tags", so things line up.

  3. #3
    Join Date
    Dec 2018
    Beans
    4

    Re: How to assign a permanent static IP address in 18.04

    The indentation is correct and was when I entered it here. It obviously was lost when I posted it. What are "code tags"?

  4. #4
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: How to assign a permanent static IP address in 18.04

    Quote Originally Posted by rudlock View Post
    The indentation is correct and was when I entered it here. It obviously was lost when I posted it. What are "code tags"?
    It was not "lost", just obscured without the code tags. There is a link in my sig telling you how to use code tags. Code tags are just one of many types of BBCode which is worth learning how to use - not at all difficult - if you are going to use a forum, any forum. If you have ever used an online forum it would almost certainly have been possible to employ BBCode to enhance your posts.

    Tip - in the message editor, click on the icon that looks a bit like A/A top-left in the toolbar and choose Source mode. Then you will be able to see the BBCode tags that you use. WYSIWYG mode is all very well but makes the use of BBCode awkward.
    Ubuntu 16.04 Desktop Guide - Ubuntu 17.10 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    Please do not PM me about your forum account unless you have been asked to. The correct place to contact an admin about your account is here.

  5. #5
    Join Date
    Nov 2012
    Location
    Halloween Town
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: How to assign a permanent static IP address in 18.04

    Thread moved to Virtualisation.

    Be sure to use spaces in groups of four for indentation as Netplan does not appreciate tabs in its yaml files.

  6. #6
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,556
    Distro
    Xubuntu Development Release

    Re: How to assign a permanent static IP address in 18.04

    Quote Originally Posted by coffeecat View Post
    Tip - in the message editor, click on the icon that looks a bit like A/A top-left in the toolbar and choose Source mode.
    Blimey! I've been using these forums since Hoary Hedgehog and I still hadn't noticed that!

  7. #7
    Join Date
    Dec 2018
    Beans
    4

    Re: How to assign a permanent static IP address in 18.04

    I still have the problem. netplan apply sets my IP address, but it's not permanent. It reverts to the DHCP address quite often. I think I'm going to give up on Ubuntu and try Mint 18.3.

  8. #8
    Join Date
    Oct 2017
    Beans
    111

    Re: How to assign a permanent static IP address in 18.04

    What I find strange in your config is the ethernet card name you use, they are no longer called "ethx";
    try to launch this command and post result:

    Code:
    ip address

  9. #9
    Join Date
    Sep 2012
    Beans
    575
    Distro
    Ubuntu Gnome 17.04 Zesty Zapus

    Re: How to assign a permanent static IP address in 18.04

    Quote Originally Posted by ubname View Post
    What I find strange in your config is the ethernet card name you use, they are no longer called "ethx";
    try to launch this command and post result:

    Code:
    ip address
    +1 and also maybe the absence of the "renderer:" element to the config?

  10. #10
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    15,444
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: How to assign a permanent static IP address in 18.04

    According to netplan.io, renderer isn't necessary and will default to systemd-networkd https://netplan.io/reference . I don't know if Ubuntu installs that renderer or not.

    Might be worth mentioning that netplan can be replaced by the old ifupdown method. There are guides for how to accomplish that. I've not used netplan or 18.04, so I don't know if these issues are common or just people getting used to yml files.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •