Wednesday 27 December 2017

Adding an IP alias to OVH dedicated server

So, as you may have guessed, recently I've moved hosting from a dedicated server at Lunarpages, to a dedicated server at OVH. Lunarpages kept the system I was on going reliably for years (indeed, I'm slowly still migrating services from it), but just couldn't match what I got included by OVH.

Anyway, to keep some things separate, I like to use separate public IPs for them. In the past, you'd just add a stanza to /etc/network/interfaces, and your work was done... but I opted for Ubuntu Server 17.10, and well - it does things differently!

Initially, I browsed around and found that there was no /etc/network/interfaces, so I assumed correctly that something later has replaced it. I did some googling and found that, indeed, Ubuntu 17.10 is released standard with "netplan". You declare your network configuration in netplan, and then from the declarative configuration, netplan then talks to whatever network management engine you've chosen and goes and configures the interfaces.

... so I went off, and did some quick reading on netplan, and all was right with the world.

WRONG

Whilst netplan is the default for Ubuntu 17.10, it's not the default for OVH deployed servers. OVH deploy their servers using our favourite system monolith, systemd. So instead of editing things in /etc/netplan/01-netcfg.yaml, I needed to look in /etc/systemd/network:

/etc/systemd/network# ls
50-default.network  50-public-interface.link
root@daserver:/etc/systemd/network# egrep '^\s*[^#]' 50*
50-default.network:[Match]
50-default.network:MACAddress=0c:c4:7a:c3:50:42
50-default.network:[Network]
50-default.network:Description=network interface on public network, with default route
50-default.network:DHCP=no
50-default.network:Address=XXXPRIMARYIPXXX/24
50-default.network:Gateway=XXXGATEWAYIPXXX
50-default.network:NTP=ntp.ovh.net
50-default.network:DNS=127.0.0.1
50-default.network:DNS=XXXDNSIPXXX
50-default.network:DNS=XXXDNSIPv6XXX
50-default.network:Gateway=XXXGATEWAYIPv6XXX
50-default.network:[Address]
50-default.network:Address=XXXPRIMARYIPv6XXX
50-default.network:[Address]
50-default.network:Address=XXXALIASIPXXX/32
50-default.network:[Route]
50-default.network:Destination=XXXXIPV6ROUTEXXX
50-default.network:Scope=link
50-public-interface.link:[Match]
50-public-interface.link:MACAddress=XXXHARDWAREMACXXX
50-public-interface.link:[Link]
50-public-interface.link:Description=network interface on public network, with default route
50-public-interface.link:MACAddressPolicy=persistent

50-public-interface.link:NamePolicy=kernel database onboard slot path mac

I had to add the highlighted [Address] block to the provided /etc/systemd/network/50-default.network file and then perform systemctl restart systemd-networkd. Unlike previous versions of linux where it'd create an alias interface and appear in an ifconfig as a separate network interface, it now only appears via:

# ip address show eno3
2: eno3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether XXXHARDWAREMACXXX brd ff:ff:ff:ff:ff:ff
    inet XXXPRIMARYIPXXX/24 brd XXXPRIMARYBROADCASTXXX scope global eno3
       valid_lft forever preferred_lft forever
    inet XXXALIASIPXXX/32 brd XXXALIASBROADCASTXXX scope global eno3
       valid_lft forever preferred_lft forever
    inet6 XXXPRIMARYIPv6XXX scope global 
       valid_lft forever preferred_lft forever

Am sure this is self explanatory to some - but I learned how to configure linux using /etc/network/interfaces, so dealing with systemd and netplan is new territory for me.

Incidentally, when I searched OVH's documentation, I initially found:
Configure a failover IP with Ubuntu
... but then when I searched again I found:
Configuring IP Aliasing: Debian 9+, Ubuntu 17+, Fedora 26+ and Arch Linux">Debian 9+, Ubuntu 17+, Fedora 26+ and Arch
... the caveat with the above link is that it's missing a d from the end of:

systemctl restart systemd-networkd <-- There needs to be a d on the end here


No comments:

Post a Comment

Hey... thanks for leaving a comment! Due to Casino spam, I've had to turn on moderation for some of the posts. Apologies - I do read every comment left!