0

Just would like to understand how you define static IP addresses for Ubuntu 17.10 server with multiple NIC adapters (i.e.eth0 and eth1) using the /etc/netplan directory. (basically a continuance from this post Ubuntu 17.10 will not accept static IP and thanks to everyone who answered this also)

here's an example of my new /etc/netplan/01-netcfg.yaml which works a treat.

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.10.254/24]
      gateway4: 192.168.10.1
      nameservers:
        addresses: [192.168.10.1,192.168.10.252]

how would I define eth1 so it could be on a different subnet (e.g 192.168.20.10/24)?

thanks in advance also!

1 Answer 1

1

The simple way, just duplicate another stanza like you have right now for your eth0, but call it eth1. Note, this assumes your cards are named 'eth0' and 'eth1' reliably:

    # <<Existing config from question goes here>>
    eth1:
      # Note, "dhcp4/6: no" not needed
      addresses: [192.168.20.10/24]
      gateway4: 192.168.20.1
      nameservers:
        addresses: [192.168.20.1,192.168.20.252]

Complete Example:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      # Note, "dhcp4/6: no" not needed
      addresses: [192.168.10.254/24]
      gateway4: 192.168.10.1
      nameservers:
        addresses: [192.168.10.1,192.168.10.252]
    eth1:
      # Note, "dhcp4/6: no" not needed
      addresses: [192.168.20.10/24]
      gateway4: 192.168.20.1
      nameservers:
        addresses: [192.168.20.1,192.168.20.252]

If you find that your cards /dev/<ifname> gives you fits, you can also match the stanza on mac address, or other properties. Adding something like the following under the correct device stanza will help. See netplan(5) for more information:

  match:
    macaddress: 00:11:22:33:44:55

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.