USE CASE: To create a persistent VIP address in a server to function as a 'loopback' address
Change to /etc/systemd/network/ directory
user@server:~$ cd /etc/systemd/network/
Create two files, 'vip.netdev' and 'vip.network'
user@server:/etc/systemd/network$ touch vip.netdev vip.network
Show the newly created files
user@server:/etc/systemd/network$ ls
vip.netdev vip.network
Edit the two files with your favorite editor to reflect the detail below
user@server:/etc/systemd/network$ more vip.netdev
[NetDev]
Name=vip
Kind=dummy
... and ...
user@server:/etc/systemd/network$ more vip.network
[Match]
Name=vip
[Network]
Address=172.16.1.23 (or whatever address you so choose)
Mask=255.255.255.255
Broadcast=172.16.1.255 (match the Address x.x.x.255)
Enable the newly created VIP interface w/out rebooting the server
user@server:/etc/systemd/network$ systemctl restart systemd-networkd
Show the newly create VIP interface
user@server:/etc/systemd/network$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.1.16 netmask 255.255.255.0 broadcast 172.16.1.255
inet6 fe80::20c:29ff:fe9b:703f prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:9b:70:3f txqueuelen 1000 (Ethernet)
RX packets 244 bytes 32605 (32.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 653 bytes 51807 (51.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 411 bytes 66247 (66.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 411 bytes 66247 (66.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vip: flags=195<UP,BROADCAST,RUNNING,NOARP> mtu 1500
inet 172.16.1.23 netmask 255.255.0.0 broadcast 172.16.255.255
inet6 fe80::d0a7:56ff:fe83:95ff prefixlen 64 scopeid 0x20<link>
ether d2:a7:56:83:95:ff txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7 bytes 490 (490.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
... or ...
user@server:/etc/systemd/network$ ip a
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:9b:70:3f brd ff:ff:ff:ff:ff:ff
inet 172.16.1.16/24 brd 172.16.1.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe9b:703f/64 scope link
valid_lft forever preferred_lft forever
3: vip: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether d2:a7:56:83:95:ff brd ff:ff:ff:ff:ff:ff
inet 172.16.1.23/16 brd 172.16.255.255 scope global vip
valid_lft forever preferred_lft forever
inet6 fe80::d0a7:56ff:fe83:95ff/64 scope link
valid_lft forever preferred_lft forever
Best Answer
I installed Ubuntu Server and surprising enough it asked me if I wanted to to setup bonding.
This is the yaml file that was setup:
I will update this as I learn more about the newer style of networking configuration in Ubuntu.
UPDATE
To change this to be static address do the following:
!Note! Your default *.yaml file name may be different.
!Note! You can name your config file whatever you want just make sure it ends with .yaml
In this file (my-network-file.yaml) copy from above and append the following changes:
Make sure you change the ip addresses to reflect your network. After this, I just rebooted the machine and my new network config was loaded and working.
You can alternatively use:
This should apply the new config without a need for a reboot.
Side Note You may want to observe spacing and not use tabs as this may cause issues with your config file.
If you're unsure of your network interfaces you can do one of the following
or
Hope this helps!