Date: Mon, 13 Jan 2003 15:10:31 +0100 From: Anand Buddhdev <arb@anand.org> To: questions@freebsd.org Subject: Re: Multiple network cards with IP addresses in the same network Message-ID: <20030113141031.GA11679@anand.org> In-Reply-To: <3E22B6B4.70401@potentialtech.com> References: <20030113114954.GQ1330@anand.org> <3E22B6B4.70401@potentialtech.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jan 13, 2003 at 07:53:08AM -0500, Bill Moran wrote: > >I have a FreeBSD 4.7 system, with 3 ethernet cards. The first two > >are recognised as fxp0 and fxp1 and the second as em0 (intel gigabit > >card). I configured the em0 with address 192.168.0.1/24. I then wanted > >to configure fxp0 with the address 192.168.0.2/24, and also connect it > >to the switch so that I can connect to the server via both addresses. > >However, FreeBSD's ifconfig command fails, and won't let me add the second > >address to the fxp0 interface. I read the manual page about ifconfig, > >and read about aliases, where it said that for aliases, I must use the > >netmask /32. When I do try to add the second address with a netmask of > >/32, it works, but it doesn't make sense to me. How is that interface > >going to to know that it is part of a /24 network if I use a /32 netmask? > > > >Would anyone be kind enough to explain why: > > > >1. For aliases, I need the /32 mask > > I didn't know that you did. I've certainly had aliases that weren't /32 I have been using linux for about 2 years now. Let me explain why I don't understand. 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. 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? > >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 This adds 2 default routes in the linux kernel, telling it to route packets to the outside world using either network interface, where eth0 has address 192.168.0.1/24 and eth1 has address 192.168.0.2/24. What's wrong with that? > If you want this setup as a failover solution, there are other ways. > There's a program in the ports (I can't remember the name, you'll have to > do some research) that will monitor an interface, and if it becomes non- > responsive, run a script of your choosing. Thus, you can have it start > up the other network card if the first fails. Ok, I understand that, and it may be a very useful program, *if* you want to bring up the other interface with perhaps the same IP address. 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? > If failover isn't what you're looking for, then I'd reconsider your > network topology. It doesn't really make sense to have 2 NICs with the > same network number in one machine. Why not? I haven't seen any such warning in my IP networking books or courses. -- Anand Buddhdev http://anand.org 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?20030113141031.GA11679>