Date: Mon, 22 Sep 1997 22:32:04 -0400 (EDT) From: Brian Clapper <bmc@WillsCreek.COM> To: questions@FreeBSD.ORG Subject: Re: Routering questions Message-ID: <199709230232.WAA00748@current.willscreek.com> In-Reply-To: <95997530@toto.iv>
next in thread | previous in thread | raw e-mail | index | archive | help
Paul Dekkers wrote: > Hi > > I have the following setup: > ________ _________ _________ > |_router_|---|_diac-gw_|---|_chippie_| > > well, let's say I have 192.168.192.192/255.255.255.240 > router has 192.168.192.193 and diac-gw 192.168.192.194 and I gave > 192.168.192.196 to chippie... > how can I reach the router (and the internet) from chippie? (and I must be > able to reach chippie from the router/internet too...) > diac-gw is a linux box, and chippie a FreeBSD... > > I tried the following on diac-gw: > arp -s 192.168.192.196 [one of the network-card-id's of diac-gw] pub > but If I do a traceroute from another host on the internet I didn't manage > to reach chippie, the traceroute couldn't pass the router... > I think that I have to set up a static route on the router in that case??? > > well, and then the other, FreeBSD, problem: > I have to setup the same network on the FreeBSD of course, and so I did, I > set up an ethernet device for 192.168.192.196 and netmask 255.255.255.240 > and now I can reach diac-gw, but I can't find the router, and thats normal > because the FreeBSD can't reach it of course because it isn't on its > subnet... How do I let the FreeBSD know that I can reach the host via > diac-gw? Your problem is that with a netmask of 255.255.255.240, you've essentially configured all three systems to think they're on the same subnet, when, of course, they're not. BTW, you only mentioned one address for `diac-gw'. What's the other one? HOST IP ADDRESS NETMASK ADDRESS MACHINE IP ADDRESS IN HEX IN HEX PORTION ------------------------------------------------------------------------ router 192.168.192.193 0xc0a8c0c1 0xfffffff0 1 diac-gw 192.168.192.194 0xc0a8c0c2 0xfffffff0 2 chippie 192.168.192.196 0xc0a8c0c4 0xfffffff0 4 ------------------------------------------------------------------------ I'm going to make a few assumptions here, before I suggest a solution: 1. You're stuck with a 4-bit host address space. That is, someone allocated you a hunk of a class C network address and dictated that you use only the lower 4-bits for host addresses. 2. You have complete control of the router, the Linux box and the FreeBSD box. 3. You only need one gateway. 4. All machines behind the gateway should be pingable from the router, and vice-versa. Assuming those are correct, what you want to do is further subnet the already-subnetted class C you were given. Steal one more bit from the host portion, leading to a netmask of 0xfffffff8 (255.255.255.248), leaving three bits for host addressing. You have control of that last network bit--the one we just stole from the host nybble. You'll use it to define two sub-subnets, a `0' net and a `1' net. Then, set your systems up like this: - Subnet 0 will have addresses between 0xc0a8c0c1 (192.168.192.193) and 0xc0a8c0c6 (192.168.192.198). - Subnet 1 will have addresses between 0xc0a8c0c9 (192.168.192.201) and 0xc0a8c0ce (192.168.192.206). Addresses 0xc0a8c0c1 (192.168.192.193, on subnet 0) and 0xc0a8c0c8 (192.168.192.200, on subnet 1) are unusable because they correspond to a host address of `0', which is reserved for machines that don't know their IP addresses. Addresses 0xc0a8c0c7 (192.168.192.199, on subnet 0) and 0xc0a8c0c8 (192.168.192.207, on subnet 1) are also unusable as host addresses because they correspond to a host address of all 1s--the broadcast address for the subnet. This means you have six addresses per subnet, for a total of 12 possible legal addresses (as opposed to 14 addresses if you didn't subnet your subnet, as it were). Now we can assign values to the various interfaces. Let's put the router and one interface of `diac-gw' on subnet `0'. We'll put the FreeBSD box and the other interface of `diac-gw' on subnet `1'. I've chosen arbitrary addresses. [ <Router-O Router-I> ] ------ [ <diac-gw-0 diac-gw-1> ] ------ [ chippie ] `Router-O' is the outside interface of the router--the interface that goes to places outside your little network (presumably to your ISP). We're not concerned with that one at the moment (though you'll have to be sure to set it up correctly, too.) `Router-I' is the inside interface of your router, the interface on your network. It's going to be on subnet 0. We'll assign it host address `1' on that subnet. `diac-gw-0' is the address of your Linux box's interface card which is on subnet `0'. We'll assign it host address `2' on that subnet. `Diac-gw-1' is the address of your Linux box's interface card which is on subnet `1'. We'll assign it host addresss `2' on that subnet. Thus, your gateway's host address portion is `2' on both subnets. Chippie gets host address `1' on subnet `1'. All machines have the same netmask, 255.255.255.248. Here then are the addresses: S U B N E T 0 IP ADDRESS NETMASK ADDRESS MACHINE IP ADDRESS IN HEX IN HEX PORTION ------------------------------------------------------------------------ router-I 192.168.192.193 0xc0a8c0c1 0xfffffff8 1 diac-gw-0 192.168.192.194 0xc0a8c0c2 0xfffffff8 2 ------------------------------------------------------------------------ S U B N E T 1 IP ADDRESS NETMASK ADDRESS MACHINE IP ADDRESS IN HEX IN HEX PORTION ------------------------------------------------------------------------ diac-gw-1 192.168.192.202 0xc0a8c0ca 0xfffffff8 2 chippie 192.168.192.201 0xc0a8c0c9 0xfffffff8 1 ------------------------------------------------------------------------ When you `ifconfig' the two interfaces on the Linux box, it should automatically set up a routing table entry between the `0' subnet and the `1' subnet. Use `netstat -r' to confirm that the routing tables are set up properly. If the above is gibberish to you, then you need to do some more reading about IP addressing. What's the moral of this story? That's simple: Subnetting class C's is pain in the ass. ----- Brian Clapper, bmc@WillsCreek.COM, http://WWW.WillsCreek.COM/ Nothing in progression can rest on its original plan. We may as well think of rocking a grown man in the cradle of an infant. -- Edmund Burke
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709230232.WAA00748>