Using multiple IP addresses at once

Ever needed to configure a network-based device using a web interface, but found that its default IP address doesn’t match the setup of your network? e.g. Your new device uses 192.168.1.* and you use 192.168.0.* ?

Here’s an easy way to fix it: set up your machine to talk to both subnets at once. Here’s a little screencast to show how it’s done on the Mac.

2 Comments

My mind is boggling over how to do that with ifconfig, or what ifconfig reports when you have done that – and does it scale to more subnets?

Hi Dan –

On Linux, you set up extra ‘aliases’ for the interface, called things like eth0:0, eth0:1 etc. And, yes, you can have lots of them. You can add them in /etc/network/interfaces, but to do it temporarily on the command line needs something like:

sudo ifconfig eth0:0 192.168.1.14 netmask 255.255.255.0

and then

sudo ifconfig eth0:0 down

when you’ve finished.

Or, if you prefer the new ‘ip’ commands:

sudo ip addr add 192.168.1.14/24 dev eth0 label eth0:0
sudo ip addr del 192.168.1.14/24 dev eth0

In many ways this is a lot like VLANs – there’s no problem in running multiple subnets at the same time on the same underlying network, be it wired or wireless. But the thing you need to remember is that nothing will forward packets between those subnets, or to the outside world, unless you take steps to make them do so.

So, for example, you can’t just add your 192.168.0.1 router as the way for things on the 192.168.1.* network to reach the outside world, because they don’t know how to talk to even that address, nor will it know how to talk back to them.

But this trick was very useful for me recently when someone had installed a device out of reach above a customer’s ceiling without setting its network correctly…

Q

Got Something To Say:

Your email address will not be published. Required fields are marked *

*

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

© Copyright Quentin Stafford-Fraser