Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Jan 2003 07:13:34 -0800
From:      "Dax Eckenberg" <deckenberg@dweebsoft.com>
To:        "Anand Buddhdev" <arb@anand.org>
Cc:        <questions@FreeBSD.ORG>
Subject:   Re: Multiple network cards with IP addresses in the same network
Message-ID:  <007701c2bb16$5784f0c0$0a0aa8c0@dweebsoft.com>
References:  <20030113114954.GQ1330@anand.org> <3E22B6B4.70401@potentialtech.com> <20030113141031.GA11679@anand.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> I have addresses 192.168.0.1 and 192.168.0.2. I want to run different
> services on the 2 different IP addresses. In a linux system, I do:
>
> ifconfig eth0 192.168.0.1 netmask 255.255.255.0
> ifconfig eth0:0 192.168.0.2 netmask 255.255.255.0
>
> So that I have 2 different addresses bound to the same interface.
>
> On FreeBSD, if I do:
>
> ifconfig fxp0 192.168.0.1 netmask 255.255.255.0
> ifconfig fxp0 192.168.0.2 netmask 255.255.255.0 alias
>
> That fails.

It should fail, you should enter:

# ifconfig fxp0 192.168.0.2 netmask 255.255.255.255 alias

In this situation you can ignore the /32 netmask, it will act as /24.

> The ifconfig manpage states that a nonconflicting netmaks must be used
> for the alias, and suggests to use 0xffffffff. I don't understand why,
> because I don't see why one network interface cannot have more than one
> address bound to it within the same network. If I use a /32 netmask for
> the alias address, how will the kernel respond to arp requests for that
> alias address?

arp requests for .2 will be handled properly by the kernel as if it were /24.

> > >2. Adding a second IP to a *different* network card in the same server
> > >does not work if the second IP is within the network of the first one.
> >
> > Because it breaks routing and the basic concept of IP addys and netmasks.
> > If you have two NICs on the same network, how is the kernel supposed to
> > route packets?
>
> I still don't understand. In a linux system I can do:
>
> route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.0.254 dev eth0
> route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.0.254 dev eth1

To my knowledge, this is a Linux feature.  Solaris, *BSD, and others don't let you specify the network interface when you add a
route.  I know for a fact under Solaris that when you have 2 interfaces which live in the same subnet, the interface with the lowest
numbered IP will be the interface used for outbound traffic.

> All I want to do is to have 2 different IP addresses on each of the
> different interfaces in the server, where the addresses are in the
> same network. I can do it in linux. Why can't I do it in FreeBSD?
>

Good question.  I'd defer this anwser to someone a bit more intimate with FreeBSD's IP stack and routing.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?007701c2bb16$5784f0c0$0a0aa8c0>