Adding additional IP Address to ethernet interface

Scenario: You have several devices within your network, you’ve changed the address range for the network but you’ve forgotten to change one in particular. It’s easier to log into the device than to physically attend to it (it may be headless, it may not be in your immediate vicinity, or you’re just to lazy to get out of your chair to do it.

Q. How do you log into a network device that isn’t on your subnet?

A. You create an alias IP address for your current interface within the scope of the IP address you need to hit.

In this example we’ve moved a network from a 192.168.0.1 to 10.0.0.1.

The router has been configured, all the devices have been configured and you’re up and running but realised you forgot the file server in the garage. Your whole network is now setup on the 10.0.0.1 network, but the file server is sitting patiently waiting for you back on the 192.168.0.1 network.

Here’s how you would do it in linux (Ubuntu):

>$ ifconfig
enp6s0: flags=4163 mtu 1500
inet 10.0.0.5 netmask 255.255.255.0 broadcast 10.0.0.255
RX packets 6406862 bytes 7485766742 (7.4 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3920089 bytes 1566938600 (1.5 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
The old server is at 192.168.0.100, our computer was at 192.168.0.77. You can use any IP address that is not the device you want to connect to, and that is still within the same subnet range.

$ ifconfig enp6s0:0 192.168.0.77 up
Confirm it worked:

enp6s0: flags=4163 mtu 1500
inet 10.0.0.5 netmask 255.255.255.0 broadcast 10.0.0.255
ether 11:22:dd:99:4e:ee txqueuelen 1000 (Ethernet)
RX packets 6413204 bytes 7488178719 (7.4 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3925411 bytes 1568449079 (1.5 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp6s0:0: flags=4163 mtu 1500
inet 192.168.0.77 netmask 255.255.255.0 broadcast 192.168.0.255
ether 11:22:dd:99:4e:ee txqueuelen 1000 (Ethernet)
note: this won’t survive a reboot. But for most intents and purposes, this will suffice. You can log into the file server and change the IP address and jump back out.

To make it permanent we will need to edit

/etc/network/interfaces
from: https://askubuntu.com/questions/585468/how-do-i-add-an-additional-ip-address-to-an-interface-in-ubuntu-14 (modified only to match the example above)

# vi /etc/network/interfaces
Append the following to the file (This is in addition to existing information, not a replacement for it)

auto eth0:1
iface eth0:1 inet static
name Ethernet alias LAN card
address 192.168.1.7
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
Save and close the file. Restart the network:

# /etc/init.d/networking restart

Leave a comment