Netmask for IP alias in different subnets

turbo

New Member


Messages: 11

Hi all! What is the correct netmask to use for aliased IP addresses on different subnets on the same interface, runnng on a FreeBSD 8.3 box? I have two subnets: x.16/29 and y.40/29. The manual entry for ifconfig, states:

If the address is on the same subnet as the first network address for this interface, a non-conflicting netmask must be given. Usually 0xffffffff is most appropriate.
So x.21 and x.22 are on the same subnet as x.20, but y.* are not. I tried different combinations of netmaks, and they all work, so I'm not sure which one is the correct.

Would these be correct netmasks to use?

Code:
ifconfig_em0="inet x.x.x.20 netmask 255.255.255.248"
ifconfig_em0_alias0="inet x.x.x.21 netmask 255.255.255.255"
ifconfig_em0_alias1="inet x.x.x.22 netmask 255.255.255.255"
ifconfig_em0_alias2="inet y.y.y.44 netmask 255.255.255.248"
ifconfig_em0_alias3="inet y.y.y.45 netmask 255.255.255.248"
ifconfig_em0_alias4="inet y.y.y.46 netmask 255.255.255.248"
defaultrouter="x.x.x.17"
Thanks for any ideas ;)
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator
Developer

Reaction score: 2,819
Messages: 11,308

An IP address in a certain network gets its proper netmask (e.g. 255.255.255.248). An alias in that same network on the same interface gets a 255.255.255.255 netmask.

Repeat for every separate network, whether it's on the same interface or not.

So:
Code:
ifconfig_em0="inet [B]x.x.x[/B].20 netmask 255.255.255.[B]248[/B]"
ifconfig_em0_alias0="inet [B]x.x.x[/B].21 netmask 255.255.255.[B]255[/B]"
ifconfig_em0_alias1="inet [B]x.x.x[/B].22 netmask 255.255.255.[B]255[/B]"

ifconfig_em0_alias2="inet [B]y.y.y[/B].44 netmask 255.255.255.[B]248[/B]"
ifconfig_em0_alias3="inet [B]y.y.y[/B].45 netmask 255.255.255.[B]255[/B]"
ifconfig_em0_alias4="inet [B]y.y.y[/B].46 netmask 255.255.255.[B]255[/B]"
 
OP
OP
T

turbo

New Member


Messages: 11

That makes sense.

I was incorrectly interpreting the manual entry sentence that says "the first network address for this interface" as "the first IP address (of any networks) for this interface"...

Thanks for the clarification.
 

NIX-Knight

New Member


Messages: 16

DutchDaemon said:
An IP address in a certain network gets its proper netmask (e.g. 255.255.255.248). An alias in that same network on the same interface gets a 255.255.255.255 netmask.

Repeat for every separate network, whether it's on the same interface or not.

So:
Code:
ifconfig_em0="inet [B]x.x.x[/B].20 netmask 255.255.255.[B]248[/B]"
ifconfig_em0_alias0="inet [B]x.x.x[/B].21 netmask 255.255.255.[B]255[/B]"
ifconfig_em0_alias1="inet [B]x.x.x[/B].22 netmask 255.255.255.[B]255[/B]"

ifconfig_em0_alias2="inet [B]y.y.y[/B].44 netmask 255.255.255.[B]248[/B]"
ifconfig_em0_alias3="inet [B]y.y.y[/B].45 netmask 255.255.255.[B]255[/B]"
ifconfig_em0_alias4="inet [B]y.y.y[/B].46 netmask 255.255.255.[B]255[/B]"
What about gateways in this situation?
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator
Developer

Reaction score: 2,819
Messages: 11,308

There is no problem for the gateway, as long as the primary entry with the proper netmask is in ifconfig (and the gateway is in that network, of course).
 

rihad

Active Member

Reaction score: 2
Messages: 151

Why does it work even with "conflicting netmasks" then? The first one below is configured as
ifconfig_igb1="inet 172.16.1.12/24". The others in the form ifconfig_igb1_alias30="vhid 30 pass XXX alias 172.16.1.30/24 advskew N"

inet 172.16.1.12 netmask 0xffffff00 broadcast 172.16.1.255
inet 172.16.1.30 netmask 0xffffff00 broadcast 172.16.1.255 vhid 30
inet 172.16.1.40 netmask 0xffffff00 broadcast 172.16.1.255 vhid 40
inet 172.16.1.50 netmask 0xffffff00 broadcast 172.16.1.255 vhid 50
inet 172.16.1.60 netmask 0xffffff00 broadcast 172.16.1.255 vhid 60
 
Top