How to set a static IP using netplan? (running Ubuntu Bionic server)

Discussion in 'Linux/BSD/Free Systems' started by mrjayviper, Mar 13, 2019.

  1. mrjayviper

    mrjayviper [H]Lite

    Messages:
    70
    Joined:
    Jul 17, 2012
    I've followed/looked at several guides (like this one) on how to do the above.

    My problem is that no static IP is getting assigned to the built-in ethernet port. I have run
    Code:
    netplan apply
    several times. I've also rebooted the PC and still no luck.

    I am sure the ethernet port works as I was previously using it on Ubuntu 16.04 just before I decided to fresh install 18.04.2.

    Any ideas what I could be doing wrong? I am going to use the ethernet port to connect my main PC to the Ubuntu server via a crossover cable.

    If I set the ethernet port to use
    Code:
    dchp4:true
    and connect an ethernet cable from it to my modem/router and disable my WiFi card (by removing the netplan config), the PC can connect to the net without any issues.

    Thanks

    Edit: I had a look at /run/systemd/network/config-file-here and it looks correct to me. At the very least representative of the contents of the YAML file. /run/systemd/network folder was mentioned in the netplan website troubleshooting page.
    ---------------------------

    This is the output of
    Code:
    netplan --debug apply
    which also shows the contents of my YAML files. I have tried with and without dhcp4/dchp6/gateway4/renderer.

    zHuau.jpg
     
    Last edited: Mar 14, 2019
  2. B00nie

    B00nie [H]ardness Supreme

    Messages:
    7,831
    Joined:
    Nov 1, 2012
    Addresses is supposed to be in brackets, show the yaml content not the debug...
     
  3. mrjayviper

    mrjayviper [H]Lite

    Messages:
    70
    Joined:
    Jul 17, 2012
    according to the netplan examples page, brackets and what you see on the debug screenshot are both acceptable.
     
  4. FNtastic

    FNtastic [H]ard|Gawd

    Messages:
    1,346
    Joined:
    Jul 6, 2013
    I think I set mine on the network (L3 switch handling DHCP) side. I'll double check for you when I get home. I've definitely done it before with netplan, and don't remember having issues...
     
  5. FNtastic

    FNtastic [H]ard|Gawd

    Messages:
    1,346
    Joined:
    Jul 6, 2013
    I checked. I'm assigning the IP via DHCP server.

    I did look over your config. A couple suggestions, and questions.

    - Are you sure 192.168.2.1 isn't in your DHCP range and already assigned to another device? I'd suggest trying something else.

    - Add version number and renderer to the file:
    Code:
    network:
      version: 2
      renderer: networkd
    - Remove the line below "addresses:" and add something like:
    Code:
    [192.168.2.73/24]
    Yes! Do it with brackets to appease us too, please!

    - Add at least one nameserver:
    Code:
         nameservers:
           addresses: [8.8.8.8,8.8.4.4]
    - Change both the "false" to "no". This may not change the behavior, but is worth trying.