Linux IP / subnet migrations...
Changing the IP addresses / subnet will break communications with equipment unless prior arrangements are made to facilitate communications with both the old IP / subnet and new IP / subnet at the same time.
Traditionally the preferred approach is the use a secondary address on the router(s). Unfortunately it’s not always possible to use a secondary addresses on the router(s). Thankfully there is nothing that prevents the use of of a secondary address on the machine(s).
A secondary address on the router(s) is preferred because it only requires changes to be made to the router(s). Comparatively, a secondary address on the machine(s) require changes to be made to each machine, thus duplicating effort.
Secondary Addresses on the router(s)
- Change the primary IP address of the router(s) to be the new IP.
- Add the old IP to the router(s) as a secondary IP.
- Reconfigure the other equipment in the subnet.
- Remove the old secondary IP from the router(s).
Secondary Addresses on the machine(s)
- Change the primary IP address of the machine to be the new IP.
- Add the old IP to the machine as a secondary IP.
- Configure the kernel to use both new primary IP and old secondary IP addresses.
- Reconfigure the other equipment in the subnet.
- Remove the old secondary IP address from the machine.
Below is how you would add the secondary addresses to a Linux machine.
-
Add the new IP to the network interface.
ip addr add $NewIP/$NewNetmask dev $NIC
-
Create a new routing table, if it doesn't already exist, by adding it to the /etc/iproute2/rt_tables file.
-
Add the new subnet to the new routing table.
ip route add $NewSubnet/$NewNetmask dev $NIC src $NewIP table new
-
Add the new gateway to the new routing table.
ip route add default via $NewGateway table new
-
Optionally copy any routes from the main routing table to the new routing table as desired.
-
Add an IP rule to activate the new routing table.
ip rule add from $NewIP table new
$NewIP is the new maintenance IP address for the machine.
$NewNetmask is the new netmask for the machine.
$NewSubnet is the new IP network the machine is in.
$NewGateway is the new gateway IP address for the machine.
$NIC is the network interface that the new IP goes on.