1

I know that if I need to assign a static ip address I will need to use netplan in Ubuntu 18.04, and I have done exactly that and made it work.

Here is my config file:

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: yes
    enp131s0f0:
      dhcp4: no
      addresses: [10.66.0.1/24]

After I use netplan apply, the ifconfig command shows the ip address of enp131s0f0 set to 10.66.0.1 after I plug the cable into the port for "enp131s0f0". This causes a problem because if I do not plug in the cable to this port, the port itself won't get a static ip address even if the ipaddress is set in netplan, this will cause some services to fail to start (eg, isc-dhcp-server).

For example, if you have 3 ports and you have configured them like so:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp131s0f0:
      dhcp4: no
      addresses: [10.66.0.1/24]
    enp131s0f1:
      dhcp4: no
      addresses: [10.66.1.1/24]
    enp131s0f2:
      dhcp4: no
      addresses: [10.66.2.1/24]
    enp131s0f3:
      dhcp4: no
      addresses: [10.66.3.1/24]

If isc-dhcp-server is installed on all these 3 ports. The isc-dhcp-server will start only if you connect all 3 ports, if you failed to connect your cable to any one port of these 3 ports the isc-dhcp-server will fail to start because the port does not have a static address (without the cable plugged into the port), even if you set the static ip address in netplan.

So I would like to ask how to permanently assign a static address to a net port. To make it have an ipaddress before I plug in the cable... I need this because there are some ports on my server that currently I do not use (the cable is left unplugged), but I need isc-dhcp-server to start...

  • Are you using a desktop or server installation? – heynnema May 29 '19 at 15:24
  • status please... – heynnema May 30 '19 at 14:05
  • status please... – heynnema Jun 3 '19 at 13:39
0

Here's a minimal .yaml file for your configuration... this assumes that 10.66.0.2 is an available static address on your network, and that 10.66.0.1 is the proper gateway...

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: true
    enp4s0f0:
      addresses: [10.66.0.2/24]
      gateway4: 10.66.0.1
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
      optional: true # may or may not be desired, to stop 2 minute boot delay

sudo netplan --debug generate # generate config files

sudo netplan apply # apply configuration

reboot # reboot and verify operation

| improve this answer | |
  • This doesn't seem to address the OP's concerns that having network cables unplugged on various NICs is causing problems. Your config resembles the OP's very closely, is the lack of a gateway address and nameserver what's causing the issue when a cable is unplugged? – Arronical May 29 '19 at 15:44
  • @Arronical the primary problem is that OP tried to assign a static IP using (probably) the IP of the gateway. – heynnema May 29 '19 at 15:52
  • That's a good point! I missed that. They're trying to install a DHCP server so perhaps they're trying to create some sort of router? The second example shows different values in the 3rd octet so may be a possibility? – Arronical May 29 '19 at 16:01
  • @Arronical same problem there... assigning the IP to the gateway address. – heynnema May 29 '19 at 16:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.