Linux TCP/IP Routing

Hi,

Can linux be setup so that one ethernet card can be assigned 2 or more ip addresses each on a differnet subnet and route between all subnets?

Robert


Robert011497Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mart010897Commented:
Hi,

Yes, you can do that, but that assumes that all of the IP networks that you're going to be routing are being spoken on that same wire.  That having been said,  here's what you need to do:

You need to have a kernel that's set up to do both aliasing and routing.  Then, at your shell prompt as root, try this:

ifconfig

You'll (hopefully) see eth0 of the IP address you gave it happy happy.  Now you want to add another network address to eth0-- let's say 10.0.0.0 network:

ifconfig eth0:1 inet 10.0.0.1 netmask 255.0.0.0 broadcast 10.255.255.255 up

You can check that it worked by going:

ifconfig

again.  You should see an eth0 interface and an eth0:1 interface.

Then you want to add the corresponding net route thru that interface so that Linux knows it can forward packets destined for that network:

route add -net 10.0.0.0 gw 10.0.0.1

or

route add -net 10.0.0.0 eth0:1

I prefer the first form.  Now you should be good to go.  It'll act just like a linux box that has two IP interfaces in it.

Read up on your routing, and don't forget that every interface that has an IP needs to have a corresponding net route pointing to its own IP as the route to whatever net it's on.

Good luck!

Mart
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RitBitCommented:
Above description is almost accurate but you might need to enable up-forwarding in the kernel with:
sysctl -w net.ipv4.ip_forward=1

Open in new window

or
echo 1 > /proc/sys/net/ipv4/ip_forward

Open in new window

And make sure there is no firewall (iptables) blocking traffic....
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.