4

I did a lot of searching, but there seems to be conflicting info on what the proper netmask for an aliased IP address should be. Some of the conflicting info seems to be FreeBSD-specific. I'm looking for the "most technically proper" answer, if there is one.

I've been assigned x.x.x.168/29.

Here is eth0:

address x.x.x.170
netmask 255.255.255.248
gateway x.x.x.169

So the proper eth0:0 netmask should be 255.255.255.something.

EDIT: Per the comment from Chris S, I am not using FreeBSD; I am using Debian. My understanding is that FreeBSD users should use .255 for aliases. But I could be wrong, so you should do your own research.

Jeff
  • 1,406
  • 3
  • 26
  • 46
  • 4
    It should be *exactly* the same as any other IP in that range, unless you have a specific reason to restrict it to a smaller subnet. – NickW Jun 14 '13 at 11:34
  • I assume you're not running one of the BSDs, it would be important to mention that in the question. The answer is **not** the same for all OSes, despite what several people apparently think. – Chris S Jun 14 '13 at 13:34

4 Answers4

6

The netmask is per network, not per IP, so as NickW says, it should be the same for all IPs in a given network. There are corner cases where you may restrict a given alias interface further, but those are exceedingly rare.

John
  • 8,920
  • 1
  • 28
  • 34
5

Your eth0:0 subnet mask should be 255.255.255.248, unless you have some reason that you do not want eth0:0 to communicate directly with the rest of the hosts in the subnet. If you make it smaller, you will need a router to allow that IP to communicate with the rest of the network.

NickW
  • 10,183
  • 1
  • 18
  • 26
  • Thanks for the explanation. I'll leave this question open for a bit to see if anyone else wants to elaborate, but I have a feeling that's about all there is to say on the subject of "proper netmask definition." ;) – Jeff Jun 14 '13 at 11:49
2

Nick W's answer is correct.

However well you understand the theory of these CIDR network specifications, working the numbers out by hand is tedious and error prone. I recommend a tool called ipcalc which is available in the software repositories associated with many of the major Free *nix distributions. It's good for getting the calculations right, and also as an educational tool, clarifying what the numbers represent, by showing you the binary representations.

me@mine$ ipcalc 1.2.3.168/29  
Address:   1.2.3.168            00000001.00000010.00000011.10101 000  
Netmask:   255.255.255.248 = 29 11111111.11111111.11111111.11111 000  
Wildcard:  0.0.0.7              00000000.00000000.00000000.00000 111  
=>  
Network:   1.2.3.168/29         00000001.00000010.00000011.10101 000  
HostMin:   1.2.3.169            00000001.00000010.00000011.10101 001  
HostMax:   1.2.3.174            00000001.00000010.00000011.10101 110  
Broadcast: 1.2.3.175            00000001.00000010.00000011.10101 111  
Hosts/Net: 6                     Class A  
mc0e
  • 5,786
  • 17
  • 31
0

Depends on what do you need :

  • if you need the aliased IP to be used to communicate with the same network then you should use the same netmask

  • if you need the aliased IP to be used in another network (for examples, you don't want this IP to receive any broadcast or any packets from other networks, and dedicate it for a reason to another network) then assign to it the right netmask

For your information, the netmask is used to fragment your networks, so be careful not to overcross them, or you will have conflicts.

eXshade
  • 101