Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Linux TCP/IP Routing

Posted on 1997-01-24
Medium Priority
Last Modified: 2012-07-12

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?


Question by:Robert011497
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

mart010897 earned 100 total points
ID: 1584158

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!


Expert Comment

ID: 38181219
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question