Archive for the ‘Networking’ Category

Multiple IP addresses on OS X

Saturday, June 14th, 2008

A week or so ago, I ran into a strange problem on a Mac Mini server which I run in the lab where I’m currently doing my MPhil research. The server has two IP addresses bound to the same physical network interface, as I wanted to run two instances of Apache and for them both to bind to port 80. Everything had been working fine, but one day, after a reboot, the server found itself unable to connect to the Apache instance which was bound to the second IP address. Worse still, it couldn’t even ping the second IP address, which was rather worrying. This was a little annoying to say the least, as I had a cron job running which downloaded a file from the site hosted on the second IP address and saved it to the local disk.

After a bit of digging around with no luck, I started a thread on the macosxhints forums to see if anyone else was aware of a solution. The usual suggestion of “check your firewall settings” was made, but nothing had changed in that regard and starting/stopping the firewall made no difference. Eventually, someone mentioned that they had a FreeBSD box where the netmask of each additional IP address was set to 0xffffffff, rather than the 0xffff0000 which I was using. I didn’t think this could be the problem, but I decided to give it a try anyway, and to my (pleasant) surprise everything worked. A closer look at the ifconfig man page for OS X confirmed that additional IP addresses with the same subnet (as was the case in this situation) should have a netmask of 0xffffffff. Not having this meant that the server couldn’t actually resolve the MAC address of the second IP, so of course it couldn’t communicate with it at all—rather an obscure problem.

It’s still puzzling me as to why this appeared to work before, but for now I’m just glad that the problem is fixed!