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.

Enjoyed this post? Why not sign up to receive Status-Q in your inbox?

4 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

Q, thank you for giving a different way to think about this. Wow. So I have a situation with a client where the number of computers on his network are all on one subnet (192.168.1.x), but they just added a VPN Router into the mix so that he can access his office computer via VPN/VNC. The VPN Router is on 192.168.0.x and he’s trying to talk to is his office computer on 192.168.1.x. We tried using your theory to see if though his VPN LAN at 192.168.0.x he could reach his office computers on 192.168.1.x, but no go.

You made it look seemless. What are we missing? I’ll go back through the video again, and was this on your server that allowed you to do this? Our thoughts after working through the steps were that for his situation he really needed to either build a static route or routing policy or seperate VLAN to connect the two subnets so that they could talk. The goal however is after making the VPN connection, to attempt reaching his office computer on 192.168.1.x if the proper routing or routing policy or static route was created.

Since we’re not networking guys, it’s been a bit of a head scratcher. Any thoughts? Advise if you’re privy.

Cheers!

    Mark – it’s tricky to say without knowing more about your network, but the solution I outlined only works if the machines are all basically on the same open network, and just happen to have been configured with different IP addresses and subnets. If, say, you have two different subnets on two different VLANs, it’s more like having them on separate ethernets, and it won’t work unless there’s something doing routing between them.

    When you connect in through the VPN, you’re on the 192.168.0.x network, and I don’t think you can do anything on the client end to change that, unless the VPN Router is explicitly configured to allow access to 192.168.1.x as well.

    Best,
    Quentin

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