Introduction: For a long time I have been using ifconfig and /etc/network/interfaces and tools to setup the network of Ubuntu servers.
After I have installed a brand new Ubuntu 18.04 I could not use that tool any more, at least without making some system changes.
So I finally decided to adapt and see what I can do with ‘netplan’ networking system.
Here is the configutation I had in ifup/ifdown/ifconfig and co. environment:
File: /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 176.9.104.88
gateway 176.9.104.47
netmask 255.255.255.255
pointopoint 176.9.104.47
auto eth1
iface eth1 inet static
address 192.168.100.88
netmask 255.255.255.0
Here is what I found to replace this by using the ‘netplan’ system:
File: /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
lo:
addresses: [127.0.0.1/16]
eth0:
dhcp4: no
addresses: [176.9.104.88/32]
gateway4: 176.9.104.47
nameservers:
addresses: [8.8.8.8,8.8.4.4]
routes:
- to: 0.0.0.0/0
via: 176.9.104.47
on-link: true
eth1:
dhcp4: no
addresses: [192.168.100.88/24]
Apply and show the results:
netplan apply ip addr show
Result:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet 127.0.0.1/16 brd 127.0.255.255 scope global lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:16:3e:42:9c:b3 brd ff:ff:ff:ff:ff:ff
inet 176.9.104.88/32 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe42:9cb3/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:16:3e:38:23:b3 brd ff:ff:ff:ff:ff:ff
inet 192.168.100.88/24 brd 192.168.100.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe38:23b3/64 scope link
valid_lft forever preferred_lft forever