From owner-freebsd-questions Fri Jul 12 0:34: 5 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 99E4837B400 for ; Fri, 12 Jul 2002 00:34:01 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6E6C143E64 for ; Fri, 12 Jul 2002 00:34:00 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1]) by smtp.infracaninophile.co.uk (8.12.5/8.12.5) with ESMTP id g6C7XwYn045773; Fri, 12 Jul 2002 08:33:58 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost) by happy-idiot-talk.infracaninophile.co.uk (8.12.5/8.12.5/Submit) id g6C7Xqgi045772; Fri, 12 Jul 2002 08:33:52 +0100 (BST) Date: Fri, 12 Jul 2002 08:33:52 +0100 From: Matthew Seaman To: default Cc: FreeBSD-Questions Subject: Re: How to add a second subnet/router interface Message-ID: <20020712073352.GB41528@happy-idiot-talk.infracaninophi> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Jul 11, 2002 at 09:24:41AM -0500, default wrote: > I need to add a new subnet and router interface to my FreeBSD machine (one > nic) and a new router interface to access the subnet. I know that there is > some sort of problem with adding aliases that makes it so one must enter > 255.255.255.255 as the subnet mask for I.P. addresses other than the main > one. What I was wondering is how do get around this to add another subnet, > and how do I add the new router interface? Yes --- this point seems to cause some confusion. The netmask that you supply when ifconfig'ing alias interface will be 255.255.255.255 in some circumstances or eg. 255.255.255.0 (whatever the appropriate netmask for the network is) in other cases. The distinction is between the second (and subsequent) addresses on a subnet, and addresses on different subnets. An example would probably clarify things. Let's suppose that you have two networks: 172.72.0.0/16 192.168.68.0/24 and that you need your machine to use the IP numbers 172.72.0.99, 172.72.27.27, 192.168.68.1 and 192.168.68.8, all on interface fxp0. To configure this little lot, you would issue ifconfig commands as follows: ifconfig fxp0 inet 172.72.0.99 netmask 255.255.0.0 (1) ifconfig fxp0 inet 172.72.27.27 netmask 255.255.255.255 alias (2) ifconfig fxp0 inet 192.168.68.1 netmask 255.255.255.0 alias (3) ifconfig fxp0 inet 192.168.68.8 netmask 255.255.255.255 alias (4) or the equivalent in /etc/rc.conf: ifconfig_fxp0="inet 172.72.0.99 netmask 255.255.0.0" ifconfig_fxp0_alias0="inet 172.72.27.27 netmask 255.255.255.255" ifconfig_fxp0_alias1="inet 192.168.68.1 netmask 255.255.255.0" ifconfig_fxp0_alias2="inet 192.168.68.8 netmask 255.255.255.255" (1) sets up the principal address on the interface -- it doesn't matter which address out of the four is chosen, as any of them would work well enough. This is the source address the box will use for itself when making connections on that network. (2) adds another interface on the 172.72.0.0/17 network. This one gets the "all ones" netmask, as it's the second interface on the same subnet. Packets will only be sent out with this as a source address in response to a connection there. (3) adds an alias on a different subnet. It's the first address added from that subnet, so it gets the netmask appropriate for that subnet. This will be the default address the box uses on the 192.168.68.0/24 network. (4) is the second address added on the 192.168.68.0/24 network, so it gets the 255.255.255.255 netmask. Given this setup, and assuming there are no complicating factors such as the use of jail(8), if you telnet from the box to 172.72.56.1, then 172.72.0.99 will be used as the source address of the packets sent. Similarly, telnet to 192.168.68.68 will use a source address of 192.168.68.1 Conversely, telnet from 172.72.56.1 to 172.72.27.27 will elicit response packets from 172.72.27.27 as expected. Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way Tel: +44 1628 476614 Marlow Fax: +44 0870 0522645 Bucks., SL7 1TH UK To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message