Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Jan 2003 17:32:44 +0930
From:      "Michael Ritchie" <michaeljritchie@bigpond.com>
To:        <questions@freebsd.org>
Subject:   RE: Multiple network cards with IP addresses in the same network
Message-ID:  <000e01c2bc6c$7cc684f0$0400a8c0@ritchie.nailed.org>
In-Reply-To: <007701c2bb16$5784f0c0$0a0aa8c0@dweebsoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
I realise that this question has gone on further than the point at which I
am replying, but I believe it is around here that everything seems to go
astray.

From my fairly primitive understanding of the TCP stack in FreeBSD, it would
seem that in the case of two network cards being on the same subnet, one is
designated as the 'primary' card (if you like) -- in this case, 192.168.0.1,
and the other the 'secondary' card -- 192.168.0.2.

The primary card is assigned the address 192.168.0.1/24, and will be used to
send data to that designated subnet, and receive packets as per normal to
its assigned ip address.  The secondary card (with the address
192.168.0.2/32) will only be used for receiving data, because the subnet
mask does not allow packets to be sent to any address other than that card
itself.
Linux must therefore use another means by which to determine which interface
is used to send packets:  my guess would be (in the given example, the eth0
interface, whilst the eth0:0 'alias' is only used to receive data?)

As for the gateways, AFAIK, since two devices can only communicate within
their own subnets, an interface must be assigned a valid IP address in the
same subnet as the router, so that interface can communicate WITH the router
itself, which can then route the packets to another wan/lan/whatever.

Regards,
Michael


-----Original Message-----
From: owner-freebsd-questions@FreeBSD.ORG
[mailto:owner-freebsd-questions@FreeBSD.ORG]On Behalf Of Dax Eckenberg
Sent: Tuesday, 14 January 2003 12:44 AM
To: Anand Buddhdev
Cc: questions@FreeBSD.ORG
Subject: Re: Multiple network cards with IP addresses in the same
network


> 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


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?000e01c2bc6c$7cc684f0$0400a8c0>