Assigning multiple IPs in the same network to an interface
M. V.
bored_to_death85 at yahoo.com
Sat Feb 18 05:06:28 UTC 2012
>> On 2/16/12 8:08 AM, M. V. wrote:
>>> hi everybody,
>>>
>>> i have a problem with setting multiple IPs in the same network in FreeBSD:
>>>
>>> - suppose I assign two new IP addresses in the same network to eth0 with ifconfig:
>>> #ifconfig eth0 add 192.168.10.1/24
>>> #ifconfig eth0 add 192.168.10.2/24
>>>
>>> - everything works fine and the output of "netstat -r" is like what it should be:
>>> #netstat -r
>>> ....
>>> 192.168.10.0 eth0
>>> 192.168.10.1 lo0
>>> 192.168.10.2 lo0
>>> ...
>>>
>>>
- but now if I delete first IP address, connection to 192.168.10.0
network will be gone. and in output of "netstat -r" the route to
192.168.10.0 (via eth0) is gone:
>>> #ifconfig eth0 delete 192.168.10.1
>>>
>>> #netstat -r
>>> ....
>>>
>>> 192.168.10.2 lo0
>>> .....
>>>
>>>
- am i missing something here? shouldn't the route to the network
remain in routing table (because we still have 192.168.10.2 assigned to
interface)?
>>>
>>> Thanks.
>>>
>>
>> You shouldn't assign your secondary IP with a /24 mask, use /32.
>>
>> You'll run into problems otherwise.
>>
>> As a rule of thumb, your aliases = /32
>>
> What
you are doing should work fine. There were a handful of routing table
bugs fixed in the last few months that corrected this behavior. The
last
> two were just merged to stable/8 yesterday. What release are you
running?
thank you all for your replies.
Sorry I dont understand why i shouldn't be able to assign 2 IP addresses in the same net, can someone tell me why it shouldn't be possible (if it really shouldn't)? because in my head, it seems normal :-)
but even if i don't have to, shouldn't `ifconfig` at least show a warning or error message to prevent such things? because now it more seems like a bug. it successfully assigns 2 (or more) IPs in the same network (and it works fine for all of them) but then when you happen to delete one of them, everything goes down.
I have FreeBSD-8.2 amd64.
More information about the freebsd-net
mailing list