Friday, January 28, 2011

What netmask should be used on an aliased address in same subnet as the primary IP?

I have an interface with an IP in a class B subnet. I want to add another IP in the came class B as an alias on the same interface. What netmask should I use? Some people say to use 255.255.255.255, while others say to use the regular netmask of the network, i.e. 255.255.0.0 in my case. Which is correct, and more importantly why?

In case it matters, I'm using Linux (CentOS 5)

  • It should be the same netmask as the regular network connection. It's just another IP sitting on the same wire, it needs to have a matching netmask. if you did /32 it wouldn't be able to talk to anything and everything would be a foreign host to it.

    troyengel : sorry, this is just untrue. not being a hater, but /32 on an aliased IP works just fine.
    From Zypher
  • I've seen it done both ways on a lot of servers, either way works just fine in practice. As long as your normal routing is correct and the network is going out the right gateway and device, a /32 will work just as well as a /24 or /16 on an aliased IP.

    Antoine Benkemoun : I agree even though it's not the cleanest solution :)
    troyengel : I agree - I *prefer* to match the netmask of the primary IP myself, but technically if they're in the same subnet a /32 will work. Not everyone cares about crossing their Ts and dotting their Is like we do.
    From troyengel
  • Since both IPs are on the same interface, I don't see how there would be any practical differences between using /16 and /32.

    Care to elaborate on what you're trying to achieve?

    From aix

0 comments:

Post a Comment