One box with two modems and three network cards

I have two modems assigned one on eth0 81.125.25.a and one on eth1 81.125.25.b , the 1st and 2nd modem have gateway 81.125.25.x. the internal network on eth2, and the clients from The problem is at 'route' when i do:

route -n add default gw 81.125.25.x
route -n add default gw 81.125.25.x dev eth1 (because first is on eth0)


route -n add default gw 81.125.25.x
route -n add -host 81.125.25.b gw 81.125.25.x dev eth1

this doesn't work too. In the first case I have net only on eth1 and not on eth0 and in the second on nothing. If I put only the 1st modem or the 2nd and add the default route it works, but I want both to work. I don't want load balancing because on the first modem I will put 5-6 persons and on second 20+ because the second line is more powerfull. (this will be via iptables SNAT : iptables -t nat -A POSTRUTING etc..)
Can somebody tell me what can i do to make the both modems work in the same time ? If you could give me the script it will be wonderful :)
Who is Participating?
lhboiConnect With a Mentor Commented:
Try the command:
ip route add default nexthop via 81.125.25.x dev eth0 weight 1  nexthop via 81.125.25.x dev eth1 weight 1
instead of two route add commands.
make two sub networks in your lan.
connect 6 systems to one sub-net
connect 20 systems to second sbu-net
both subnet has ur linux system with modems as gateway
in gateway system add 1st subnet gw as  81.125.25.a
add 2nd subnet gw as  81.125.25.b

Gabriel OrozcoSolution ArchitectCommented:
you need routing.

iproute2 can handle this problem creating two different routing tables: one for eth0 and other for eth1.

check in

in the howto comes several examples about how to do what you want.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

keepwalkingAuthor Commented:
Can u post the script for doing this ? I don't understand what is there I mean what is $P2_NET and in my case is only 1 provider but 2 modems and the same gateway as I  said upper in the question, I want the clients from be on modem 1 and that from on the other. I'm newbie in routings and this is why I asked here because all the answers of this question are read howto's. Thanks
keepwalkingAuthor Commented:
I got the following error  :

RTNETLINK answers: Invalid argument
keepwalkingAuthor Commented:
Works now..thank lhboi
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.

All Courses

From novice to tech pro — start learning today.