0

I am at my wits end here with Netplan. I just got a brand new install of 18.04 LTS Ubuntu server running in Vbox for testing. The network interface is running in NAT mode on Vbox and there is a DHCP server. When I installed the server the enp0s3 interface got an IP address and everything was grand. However, I want to set a static IP using netplan. This is where I am lost. Here is what I did:

  1. Disable the 50-cloud-init.yaml file:

    sudo touch /etc/cloud/cloud-init.disabled
    sudo touch /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
    add `network: {config: disabled}` to `99-disable-network-config.cfg
    
  2. Create my 01-netcfg.yaml file and populate it:

    sudo touch /etc/netplan/01-netcfg.yaml
    

    And output:

    network:
      version: 2
      renderer: networkd
      ethernets:
        enp0s3:
          dhcp4: no
          addresses: [10.0.2.15/24]
          gateway4: 10.0.2.2
          nameservers:
            addresses: [8.8.8.8, 8.8.4.4]
          optional: true
    
  3. Apply the netplan:

    sudo netplan generate
    sudo netplan apply
    

    Here is the output of the syslog after:

    Dec 14 19:19:31 media systemd[1]: Stopping Network Service...
    Dec 14 19:19:31 media systemd-timesyncd[432]: Network configuration changed, trying to establish connection.
    Dec 14 19:19:31 media systemd[1]: Stopped Network Service.
    Dec 14 19:19:31 media systemd[1]: Starting Network Service...
    Dec 14 19:19:31 media systemd-networkd[1013]: enp0s3: Gained IPv6LL
    Dec 14 19:19:31 media systemd-networkd[1013]: Enumeration completed
    Dec 14 19:19:31 media systemd[1]: Started Network Service.
    Dec 14 19:19:31 media systemd-networkd[1013]: enp0s3: Link is not managed by us
    Dec 14 19:19:31 media systemd-networkd[1013]: lo: Link is not managed by us
    Dec 14 19:19:31 media systemd-networkd[1013]: enp0s3: DHCPv4 address 10.0.2.10/24 via 10.0.2.2
    Dec 14 19:19:31 media systemd-networkd[1013]: enp0s3: Configured
    Dec 14 19:19:41 media systemd-timesyncd[432]: Timed out waiting for reply from 91.189.94.4:123 (ntp.ubuntu.com).
    Dec 14 19:19:41 media systemd-timesyncd[432]: Synchronized to time server 91.189.89.198:123 (ntp.ubuntu.com).
    

What am I doing wrong here? If I reboot, nothing changes. Just for fun I added a second adapter in my Vbox and I was able to control that adapter with netplan, but not enp0s3. I have no idea what keeps overriding my netplan.

The result of cat /etc/network/interfaces is:

ifupdown has been replaced by netplan(5) on this system.  
See /etc/netplan for current configuration.  
To re-enable ifupdown on this system, you can run:  
  sudo apt install ifupdown

The output of sudo lshw -C network is:

*-network:0
   description: Ethernet interface
   product: 82540EM Gigabit Ethernet Controller
   vendor: Intel Corporation
   physical id: 3
   bus info: pci@0000:00:03.0
   logical name: enp0s3
   version: 02
   serial: 08:00:27:d5:f6:75
   size: 1Gbit/s
   capacity: 1Gbit/s
   width: 32 bits
   clock: 66MHz
   capabilities: pm pcix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
   configuration: autonegotiation=on broadcast=yes driver=e1000 driverversion=7.3.21-k8-NAPI duplex=full ip=10.0.2.10 latency=64 link=yes mingnt=255 multicast=yes port=twisted pair speed=1Gbit/s
   resources: irq:19 memory:f1200000-f121ffff ioport:d020(size=8)
  • 1
    Why did you create /etc/cloud/cloud-init.disabled and 99-disable-network-config.cfg? Is your gateway really 10.0.2.2? "dhcp: no" is not necessary, as no is the default. Show me cat /etc/network/interfaces and sudo lshw -C network. Start comments to me with @heynnema or I may miss them. Why "enp0s3: DHCPv4 address 10.0.2.10" when you requested .15? – heynnema Dec 14 '19 at 19:43
  • Is it enp0s3 or enp3s0? You call it out both ways. – heynnema Dec 14 '19 at 19:48
  • @heynnema I added that file because that is what /etc/netplan/50-cloud-init.yaml says to do. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} I have tried with and without dhcp: no I kept it in there to try and help. My gateway is 10.0.2.2 - but that doesn't really matter. I am getting a DCHP address of 10.0.2.10, but my netplan is configured for a static of 10.0.2.15. That is exactly my issue.... The netplan isn't taking affect. – b k Dec 14 '19 at 19:58
  • 1
    Please enter output as an edit in your question, rather than in the comments. I'm also looking for the lshw output. Is 10.0.2.15 a valid IP on your host network? What range of IPs are valid there? What IP address is your DHCP server? – heynnema Dec 14 '19 at 20:06
  • 1
    What I was trying to determine is if 10.0.2.15 is valid on your host network, or only on the NAT. Remove the two files, remove "dhcp: no", remove "optional: true", and make sure there are no tabs in the .yaml file. Retry and report back. – heynnema Dec 14 '19 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.