linux router

Taking care of your Linux box.
zaeemarshad
Lieutenant Colonel
Posts: 660
Joined: Sat Jul 06, 2002 12:35 pm
Location: Islamabad
Contact:

linux router

Post by zaeemarshad »

I was wondering if we can assign one ethernet interface multiple ips from different subnets( i know i can do it) and then make this linux pc act as a router between the two networks. can this be done?? thanks for any help

regards
zaeem
farhanksa
Subedar
Posts: 359
Joined: Sun Nov 03, 2002 6:40 am
Location: Lahore
Contact:

its easy but be carefull

Post by farhanksa »

u can assign 1 ethernet multiple ip's but wt u wana do from that 1 ethernet.
u need alteast 2 ethernet
command is
ifconfig eth0 192.168.0.1 255.255.255.0 up
ifconfig eth1 192.168.1.1 255.255.223.0 up

note that second ip have diff subnet mask it may be same bcz the network is different
not ur linux box will act as router btween diff networks..
have u ever tried to give a static route to any WAN ip? or used ospf in linux??
farhanksa
Subedar
Posts: 359
Joined: Sun Nov 03, 2002 6:40 am
Location: Lahore
Contact:

www.linuxrouter.org

Post by farhanksa »

aoa
it will help u a lot
www.linuxrouter.org
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Re: its easy but be carefull

Post by lambda »

farhanksa wrote: u need alteast 2 ethernet
not needed. try this:

ifconfig eth0 inet <ip-on-subnet1> netnask <the-netmask>
ifconfig eth0:1 inet <ip-on-subnet2> netmask <the-netmask>
ifconfig eth0:2 inet <ip-on-subnet3> netmask <the-netmask>
...

echo 1 > /proc/sys/net/ipv4/ip_forward (or whatever that file's called).
zaeemarshad
Lieutenant Colonel
Posts: 660
Joined: Sat Jul 06, 2002 12:35 pm
Location: Islamabad
Contact:

Post by zaeemarshad »

Well i tried it earlier what you wrote in your last email. well actually what i did was something like this on my linux pc

ifconfig etho:0 192.168.0.1 netmask 255.255.255.0 up
ifconfig eth0:1 10.0.0.1 netmask 255.0.0.0 up

then i gave my windows machine an ip of 192.168.0.2 and gave it the gateway address of 10.0.0.1 and it could easily ping the linux router but it could not ping other machines on the 10.0.0.0 subnet. that's where i am confused. any help. i am thinking of using zebra instead of static routes. a bit too much for such a task but it will work. dynamic routing is always easy.....

regards
zaeem
farhanksa
Subedar
Posts: 359
Joined: Sun Nov 03, 2002 6:40 am
Location: Lahore
Contact:

if u dont have 2 ehternet then how can u reoute

Post by farhanksa »

aoa

if u have 1 ether net then only way is that u have switch or hub on the way.
then ur single ehternet can listen to the broadcasts or unicasts.

pls also check can u ping other 10.0.0.? machnices from 10.0.0.1
also try to change the gateway for toher machines
fawad
Site Admin
Posts: 918
Joined: Wed Aug 07, 2002 8:00 pm
Location: Addison, IL
Contact:

Post by fawad »

zaeemarshad,
Do you have a firewall enabled? If so, try removing that. Second, make sure the net.ipv4.conf.all.forwarding parameter is set to 1. I know that this does work because I used to do this when I couldn't afford a second NIC for my home machine :)
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Post by lambda »

zaeemarshad wrote:then i gave my windows machine an ip of 192.168.0.2 and gave it the gateway address of 10.0.0.1 and it could easily ping the linux router but it could not ping other machines on the 10.0.0.0 subnet.
you gave a machine on the 192.168.0.x network a 10.0.0.x ip for its gateway? that won't work. the gateway has to be on the same network. that's why it's called a "gateway" -- it provides a path to other networks.
that's where i am confused. any help. i am thinking of using zebra instead of static routes. a bit too much for such a task but it will work. dynamic routing is always easy.....
you want to use dynamic routes for two networks that are connected to the same router? that would be a very interesting exercise, if somewhat academic. however, solve the first problem before trying this. it's a lot easier to debug.
Babarq
Lance Naik
Posts: 28
Joined: Fri Mar 07, 2003 12:30 pm

communicate

Post by Babarq »

aoa
the IP Ranged 10.x.x.x will never be on the same Lan as 192.x.x.x ....

The Gate way would never communicate as Classes are Totally different
try to give windows an IP of something Like 10.0.0.x range

Hope it helps
Regards
BQ
zaeemarshad
Lieutenant Colonel
Posts: 660
Joined: Sat Jul 06, 2002 12:35 pm
Location: Islamabad
Contact:

Post by zaeemarshad »

it seems like i didnt explain the scenario right. let me explain again. we have a 192.168.168.x network with about 20 pcs connected using a hub. what i did was that i assigned 10 pc(both linux and win boxes) to a 10.0.0.x network. now as these both are on different subnets we need a router to communicate between the two subnets. as we are on a hub i assigned one of the linux machines two ips on eth0. one was virtual i.e. it was 10.0.0.1 on eth0:0. so the settings for the linux router are

192.168.168.1 on eth0
10.0.0.1 on eth0:0

now i enabled ip forwarding but nothing seems to get through from one subnet to the other. i hope this explains the problem. also i added the two networks using the route command. any help????
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Re: communicate

Post by lambda »

Babarq wrote:the IP Ranged 10.x.x.x will never be on the same Lan as 192.x.x.x ....
they can be on the same lan. they just won't be on the same subnet.
zaeemarshad
Lieutenant Colonel
Posts: 660
Joined: Sat Jul 06, 2002 12:35 pm
Location: Islamabad
Contact:

Post by zaeemarshad »

:P
I know about the fact that you pointed out and this is why i posted this post so that i can get a router to communicate between the two subnets.

thanx
sakbar
Naik
Posts: 88
Joined: Wed Aug 07, 2002 8:00 pm
Location: Lahore
Contact:

Post by sakbar »

Correct me if iam wrong ..

what if linux machine can act as bridge in this situation !

--shakeel
zaeemarshad
Lieutenant Colonel
Posts: 660
Joined: Sat Jul 06, 2002 12:35 pm
Location: Islamabad
Contact:

Post by zaeemarshad »

a bridge will pass on all packets between the two subnets and this will choke the network bandwidth which i simply dont want apart from security considerations and access controls.

cheers
farhanksa
Subedar
Posts: 359
Joined: Sun Nov 03, 2002 6:40 am
Location: Lahore
Contact:

did u ever use

Post by farhanksa »

aoa
did u ever use the subnet zero and subnet one with the linux box router..
and how many sub eth interface does linux supports??may be 256
Post Reply