cheap but useful trick with alias network interface
November 4th, 2006How many times did you have to change the IP address of your workstation to match the IP subnet of that new network device you needed to configure, maybe just to change its address from the default?
How many times did you need to check something on the Internet during the process, and you had to switch addresses back and forth, maybe many times? Worse still, did you like all your TCP connections such as your umpteen IM logins, ssh sessions, VPN tunnels and the like, to be shut down on the occasion?
If you do my job, it happens a lot of times. But never before this morning had occurred to me that there is a smarter way to do that, if you’re under some sort of un*x operating system like GNU/Linux(*).
Suppose you have a device on 192.168.1.1/24 (if you don’t know about CIDR, this may be a good time to learn something about it) and your workstation’s interface, let’s say eth0, is on a different IP subnet (but of course plugged into the same Ethernet network). You can do like this (as the root user):
# ifconfig eth0:0 192.168.1.100 netmask 255.255.255.0
As you may have guessed, this command adds an alias interface for eth0 called eth0:0, and assigns it the specified IP address. You can use this interface in the same ways you would use eth0, e.g. using your web browser to reach the new device’s web-based configuration interface at http://192.168.1.1 or whatever else.
The good thing is that this does not affect your main interface and the associated routing, so your existing connections don’t get killed.
Once you’re done, you can remove the alias interface:
# ifconfig eth0:0 down
and you’re back to your routine.
A couple of notes to the tech-savvy:
- (*) You can add multiple IP addresses on Windows also (from Windows 98 on, I believe). Just add a new IP address to the interface. I don’t know (nor care about) the details, though.
- Adding the alias interface automagically adds a route for the new interface’s IP subnet, but of course does not change your default route. If your new device is a router and you want to reach networks behind it, you’ll need to add specific routes to your system.
- You may unwillingly expose services running on your workstation which are listening on all interfaces (
TCP *:port)

cat >/dev/null is a collection of 


