![]() ESN 10280-090306-199360-80 |
|
Document Name: Multiple IP addresses on one interface Document Description: Multiple IP addresses on one interface2009/03/06 My wife's XP machine gets very confused about my MacBook. Sometimes it thinks I'm at 192.168.2.3 but sometimes it thinks "Macbook" is 192.168.2.2 instead. I have no idea why it thinks this: I use a static 192.168.2.3 address always and it doesn't change.. well, except maybe when I'm fooling around with something. Maybe that's when the poor XP gets confused. Honestly, I feel sorry for it. There it is, the lone Windows machine on the network, surrounded by Linux and Mac boxes. It must get lonely. Oh, once in a great while I'll fire up Windows in a VM on the Mac, but that's rare and usually only lasts a few minutes at best. How would you feel if you were a little XP box, already burdened by a crappy OS and bloated anti-virus software and you were surrounded by happy, carefree Linux and Mac machines that get to do all the fun stuff? Maybe you'd "accidentally" forget a few IP addresses now and then, wouldn't you? Maybe sometimes you'd just feel so sorry for yourself that you'd dive down into your anti-virus software and just stay there, refusing to do anything else.. Of course that annoys my wife. "It can't find Macbook", she informs me, disappointment tinging her voice. I really believe that she thinks my Macbook is deliberately hiding from her machine. Perhaps it's a cruel game OS X enjoys tormenting XP with - "bet you can't find me.. look, I'm over here.. no I'm not!". And the Linux boxes stand off to the side laughing heartily while the bewildered little XP machine once again looks under the router and finds nothing but dust. I took pity on it and decided to do something to help it out. As it mostly seems to think the Macbook has become 192.168.2.2 when it actually has not, I felt that assigning both addresses to the box would help solve the problem. That's called an "alias" and is a fairly common need. For example, if we want to change the address of a server but a number of clients on the network are hardcoded with the old IP address, adding the old address as an alias solves the problem until we can get around to fixing up the clients. Note that this can be done while renumbering a network. If your old network was 10.1.1.0 and you are switching to 192.168.2,0, you can give the server its new 192.168.2.10 address and put a 10.1.1.10 alias on the same interface. The clients that haven't yet been switched to the new scheme will happily talk to the alias address. However, it can be useful when consolidating functions also. I had a client with a file server and a mail server. The file server was at 192.168.8.240, the mail server was at 192.168.8.250. The mailserver hardware died so we moved it to the 192.168.8.240 machine. As some clients expected to find the mailserver at the 250 address, we simply added that as an alias. Given the usefulness of this, you'd think it would be easy to do. Actually it is, but both OS X and Linux require that you do this at the command line. I find that particularly odd on OS X as the System Preferences Network Panel does allow you to create VLANS and bond multiple interfaces even on the ordinary client version. But adding an alias? Command line work. For Linux, it's "ifconfig eth0:0 192.168.1.3". You could add another with "ifconfig eth0:1 192.168.1.9" and so on. For OS X use " sudo ifconfig en0 alias 192.168.1.2 netmask 255.255.255.255". Note that the 255.255.255.255 netmask is necessary when you are adding an address that is on the same subnet as the first network address for the interface; if it's a different subnet you'd give the proper netmask. Some Linuxes use a very similar syntax: "ifconfig eth0 --add alias 192.192.31.250", for example. The "eth0:0" seems to be the most common, though. So, to help out my wife's XP, I added an alias for 192.168.2.2. on the MacBook. I also added the command to /etc/rc.common so that it will survive reboots. On Linux, I'd put it in /etc./rc.local. Even Windows XP can do this if you have set a static IP. Just click on the Advanced button in TCP/Ip Properties and add under the "IP Settings" tab. Author: Anthony Lawrence - Contact Author Publisher: Anthony Lawrence Licensee Name: Anthony Lawrence Reference URL: http://aplawrence.com/Linux/adding_ip_aliases.html Copyright: All Rights Reserved Registration Date: 3/6/2009 3:40:55 PM UTC Views: 2386 |
