[TriLUG] multiple IP from the same network card?
Chris Bullock
cgbullock at cox.net
Wed Jun 18 14:24:53 EDT 2003
Jeremy Portzer wrote:
>On Wed, 2003-06-18 at 13:56, lfwelty wrote:
>
>
>>How do the virtual interfaces work w/ different subnets if you are connected
>>via the same physical interface?
>>
>>ie. Do you have to be plugged into a switch that can handle different subnets
>>on the same interface?
>>
>>
>>
>
>Switches don't care about subnets. Switches are layer two devices and
>will move frames across the network regardless of what the IP headers
>say. (Well, that's not 100% true. But mostly.)
>
>But in general, you can have two subnets on the same physical interface,
>and the same network, and they won't talk to each other at all. Say you
>have the networks 10.0.22.0/24 and 10.0.33.0/24 on the same subnet. Any
>host/NIC in the 10.0.22.* range can talk to any other IP in the
>10.0.22.* range automatically. The same goes for the 10.0.33* range.
>Even though they're on the same physical network, the subnets describe
>which hosts "see" each other as local.
>
>If you want the different networks to talk to each other, you need
>routing. A router can be configured with multiple IP addresses on one
>interface quite easily. This is sometimes called a "router on a stick,"
>because there's only one cable plugged into it (the single Ethernet
>cable to the single NIC). This can be done with a standalone router, or
>with the Linux virtual interface setup that Jason described, simply by
>enabling IP routing. Everything will go in the NIC on one subnet, and
>out the same NIC on the other.
>
>This isn't the most efficient way of doing things, but certainly
>feasible, and often useful depending on your purposes.
>
>--Jeremy
>
>
Adding to Jeremy's reply, you can use this same machine to route between
the two subnets add this line to the rc.local
ip r add "destination network" via "destination gateway addres"
example
ip r add 10.0.22.0/24 via 10.0.22.1
ip r add 10.0.33.0/24 via 10.0.33.1
you can also do this from the command line but it will stop routing when
you reboot unless you add it to the rc.local
--chris
More information about the TriLUG
mailing list