Before migrating IP addresses, make sure to read the static networking guide to learn how configuration is performed.

Suppose your old IPv4 address is, and your new IPv4 address is The old default gateway was with subnet mask The new default gateway is, with subnet mask Your old IPv6 address is 2001:db8:1::1, and your new IPv6 address is 2001:db8:2::2. The default gateway remains the same, 2001:db8::1, with prefix length 48.

Default Gateway192.
Subnet Mask255.255.255.0 or 0xffffffff255.255.255.128 or 0xffffff80
Default Gateway2001:db8::12001:db8::1
Prefix Length4848

Configuring /etc/hostname.if

First you will need to configure your hostname.if configuration file. If you have a virtio network device, edit /etc/hostname.vio0 to the following:

inet 0xffffff80
inet alias 0xffffffff
inet6 2001:db8:2::2 48
inet6 alias 2001:db8:1::1 48

The first line configures the IP addresses, The subnet mask here could be written as either (in dotted quad notation) or as 0xffffff80 (in hexadecimal notation). They are both equivalent.

The second line creates an aliased IP address This will allow your VPS to use either IP address. The subnet mask here should be set to 0xffffffff or because it's an aliased IP address.

The third line configures the IPv6 address 2001:db8:2::2 with a prefix length of 48. The fourth line configures the alias 2001:db8:1::1, with a prefix length of 48.

Configuring /etc/mygate

You will next need to update your default gateway:

Restarting networking

Disable the network interface, flush old routes, then restart networking:

WARNING: This step will cause network disconnections. If any files are misconfigured, you may not be able to reconnect. Make sure you have serial console access before proceeding:

$ doas ifconfig vio0 down && doas route flush && doas sh /etc/netstart

Stale hostname

If you change your host's IP address, double check /etc/hosts to ensure there are no old, stale values that could intercept name lookup.

Test New IP Adddress

After adding an IP address, make sure to test it using ping, netcat, and traceroute?.

For example:

$ ping -I
$ ping6 -I 2001:db8:2::2 2607:f8b0:400a:80a::200e

If after waiting 30 seconds, ping shows 100% packet loss, then networking has failed.

Other Network Services

Static NetworkingUpdate ifconfig, /etc/mygate, and /etc/hostname.if0
NSDUpdate the IP addresses in nsd.conf, and update records in zone files
ZNCUpdate the IP addresses in znc.conf's listeners
ngircdUpdate the Listen = IP addresses in ngircd.conf
UnboundUpdate the outgoing-interfaces in unbound.conf
RelaydUpdate IP addresses in relayd.conf
Packet FilterUpdate Packet Filter
PingTroubleshoot networking using ping
NetcatTroubleshoot networking using netcat