Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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)

share|improve this question
    
Assuming you mean /16 when you say Class B... The mask tells an interface the two parts of an address, network and host. So if you had 192.168.254.42 /24 as an IP address on the interface and you wanted to add another IP address in network 192.168.254.0 as an alias it should also have a /24. /32 wouldn't be a good practice. –  dbasnett Oct 7 '10 at 14:58

3 Answers 3

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.

share|improve this answer
    
I agree even though it's not the cleanest solution :) –  Antoine Benkemoun Oct 7 '10 at 15:22
    
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. –  troyengel Oct 7 '10 at 16:12

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?

share|improve this answer

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.

share|improve this answer
1  
sorry, this is just untrue. not being a hater, but /32 on an aliased IP works just fine. –  troyengel Oct 7 '10 at 16:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.