• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

Linux TCP/IP Routing


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?


1 Solution

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:


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 network:

ifconfig eth0:1 inet netmask broadcast up

You can check that it worked by going:


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 gw


route add -net 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!

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

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

Open in new window

And make sure there is no firewall (iptables) blocking traffic....

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now