[wplug] Two Subnets?

Hagbard Celine wplug at wplug.org
Wed Aug 18 00:37:51 EDT 2004


On Tue, Aug 17, 2004 at 01:19:05PM -0400, wplug wrote:
> Needing a little help here.
> 
> I have two Linux servers using two different subnets connected via a
> hub. I want each to see the other but not sure how to set this up?
> 
> Thanks,
> Ken
> 
Hoping I can be of a little assistance...

I run two subnets, I'll try to strip my configuration to the basics.
There are two routers (one for each subnet), each router has two network cards.
There are three hubs (one for each router's communication with its own subnet,
one for the routers to talk to each other).  The routers both run linux-2.4.25

The /etc/init.d/network files

Router 1:
ifconfig eth0 172.16.0.1 netmask 255.255.255.0 broadcast 172.16.0.255
ifconfig eth2 172.16.1.1 netmask 255.255.255.0 broadcast 172.16.1.255
route add -net 172.16.2.0 netmask 255.255.255.0 gw 172.16.0.2
echo 1 > /proc/sys/net/ipv4/ip_forward
(Some stuff for the Internet connection on this router)
(A whole bunch of stuff for iptables)

Router 2:
ifconfig eth0 172.16.0.2 netmask 255.255.255.0 broadcast 172.16.0.255
ifconfig eth1 172.16.2.1 netmask 255.255.255.0 broadcast 172.16.2.255
route add -net 172.16.1.0 netmask 255.255.255.0 gw 172.16.0.1
echo 1 > /proc/sys/net/ipv4/ip_forward
(Some stuff for the Internet connection on *this* router [yes, I have two
Internet connections])
(A bigger bunch of stuff for iptables)


What's going on

The two subnets employ a total of three networks; each subnet is a network in
its own right, and there is one more network through which the two subnets talk
to each other.  After you've issued the 'ifconfig' commands, a given router
is able to talk to the machines on its own subnet and the other router; this is
because the 'ifconfig' commands set up the networks for their own interfaces.
The 'route' command on a given router specifies that the other router is the
gateway for the machines on that other router's network.

You could conceivably get away with two machines and a single hub if you put
the servers *on* the routers; I'm not a big fan of that setup, however, for
reasons involving security.  In my admittedly warped little world, routers
route, servers serve, and ne'er the twain shall meet...  Even with such a
hardware configuration, you would still need three networks, though, to keep
the subnets separate.

I hope this is of *some* help, and not a totally confused mess.  If you want
to, you can tap my shoulder via <hceline at softhome dot net>.

Hagbard




More information about the wplug mailing list