[plug] Separate networks on switch

Cameron Patrick cameron at patrick.wattle.id.au
Mon Jun 6 21:24:55 WST 2005


J Michael Gilks wrote:

> I have 2 networks at home, eg 192.168.200.* and 192.168.201.*
> If I connect hosts from both networks to a switch will they still be able to 
> communicate.

Yes.

> I am sure this won't work with a hub, but it would save some wiring if it 
> would work with an unmanaged switch.

It will work with a hub too.

Note that with either an unmanaged switch or a hub, you'll have no
kinds of security benefits from separating the two networks.
i.e. don't do it this way if you're trying to have a DMZ separated
from your LAN or something.

> Can anyone help me out with this please.

You need to make one machine a router (with IP addresses on both
networks - they can be associated with the same network card though)
to will exchange packets between the two subnets.

e.g.
# ifconfig eth0 192.168.1.1 netmask 255.255.255.0
# ifconfig eth0:0 192.168.2.1 netmask 255.255.255.0
# echo 1 >/proc/sys/net/ipv4/conf/all/forwarding

Setting this to happen automatically when the machine boots is distro
dependent.

This will give you two "virtual" interfaces on eth0 with different
IPs, and tell the kernel to forward packets between them.

Then each machine on 192.168.1.x should have their default route set
to 192.168.1.1, and each machine on 192.168.2.x should have their
default route set to 192.168.2.1.  (It is possible but not necessary
to have this router also be your "outside" network link, e.g. if
you're using an ADSL router it can have its default route set to that,
and so packets will go from e.g. 192.168.1.42 (random machine) ->
192.168.1.1 -> 192.168.1.2 (adsl router) -> internet; or 192.168.1.1
might also be directly plugged into a modem and pass packets straight
out.)

Whee, that ended up being longer than expected, hope it's useful!

HTH,

Cameron.




More information about the plug mailing list