I have a couple Ubuntu Server 16 installations where the NIC gets a static address and a dhcp address using the interface:X
syntax in the /etc/network/interfaces file.
auto eno1
iface eno1 inet static
address 172.16.12.18
netmask 255.255.252.0
network 172.16.12.0
broadcast 172.16.15.255
gateway 172.16.12.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.16.0.3 172.16.8.7 8.8.8.8
auto eno1:1
iface eno1:1 inet static
address 172.16.13.18
netmask 255.255.252.0
network 172.16.12.0
broadcast 172.16.15.255
gateway 172.16.12.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.16.0.3 172.16.8.7 8.8.8.8
auto eno1:0
iface eno1:0 inet dhcp
This results in the server above getting the two static and one DHCP addresses below.
$ ip addr show eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 48:0f:cf:63:09:91 brd ff:ff:ff:ff:ff:ff
inet 172.16.12.18/22 brd 172.16.15.255 scope global eno1
valid_lft forever preferred_lft forever
inet 172.16.13.18/22 brd 172.16.15.255 scope global secondary eno1:1
valid_lft forever preferred_lft forever
inet 172.16.15.27/22 brd 172.16.15.255 scope global secondary eno1:0
valid_lft forever preferred_lft forever
I installed Ubuntu Server 18 yesterday and found netplan was the preferred network manager. I was able to add multiple IPs in the yaml config for netplan, but the addresses are both static. I'd like to get one static and a DHCP address.
# cat /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eno1:
addresses: [ 172.16.9.250/22 , 172.16.10.250/22 ]
gateway4: 172.16.8.1
nameservers:
search: [ staff.example.com , example.com ]
addresses:
- "172.16.8.7"
- "172.16.0.3"
The reason I want a static and dynamic is a holdover from a fix I found on the NFS server I set up a couple years ago. One of the old Solaris machines couldn't connect to the 12.18 address above, so I would add another static address - and later configure the NFS server to get a DHCP address - and the flaky Solaris server could mount the NFS volume on the additional IPs.
Is it possible to configure netplan to get a DHCP address and assign a static address on the same interface?