Use specific interface for outbound connections (Ubuntu 9.04)

I have 2 ethernet user interfaces in my computer system, which is running Ubuntu 9.04. Both user interfaces sporting activity fixed IPs, yet make use of different portals. My /etc/network/interfaces documents looks something similar to this:

auto eth0 eth1
iface eth0 inet static
  address 10.0.0.5
  netmask 255.255.255.0
  gateway 10.0.0.1

iface eth1 inet static
  address 192.168.2.5
  netmask 255.255.255.0
  gateway 192.168.2.1

I intend to have all website traffic mosting likely to the internet - at - huge go through eth0, yet it appears to intend to experience eth1. Exists a manner in which I can funnel my basic outgoing website traffic via eth0 rather and also just make use of eth1 for website traffic to its subnet?

The solution needs to be relentless ; that is to claim, it needs to endure reboot without a superuser requiring to run a command after reactivate.

EDIT : as asked for, below is the result of my route -n command:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth1
0.0.0.0         192.168.2.1     0.0.0.0         UG    100    0        0 eth1
0.0.0.0         10.0.0.1        0.0.0.0         UG    100    0        0 eth0
8
2022-06-07 15:17:26
Source Share
Answers: 4

Look at your existing routing table by keying in course. Your equipment will certainly make use of the first default gw it sees in the routing table. This will certainly be represented by default or 0.0.0 .0 as the location. If you just desire eth1 to be made use of for the neighborhood 192.168.2.0 /24 network, remove the portal command. This need to make eth1 is default gw your only default one.

1
2022-06-07 15:50:01
Source

Modifing the routing table with course as recommended will certainly repair this momentarily, yet it will certainly change to it is existing state on the next boot.

It would certainly be feasible to set course regulations in/ etc/rc. neighborhood or some sort of various other init manuscript, yet in this instance the most basic alternative is simply to remove the portal from eth1 in the user interfaces documents.

By getting rid of that portal that system will certainly still instantly make use of eth1 as the course 192.168.2/24, yet will certainly course all various other website traffic via eth0.

2
2022-06-07 15:49:20
Source

You need to just have one default portal. If you remove the portal line from eth1, it'll all simply job (after networking is reactivated).

12
2022-06-07 15:47:49
Source

Remove portal from eth1 in/ etc/network/interfaces and also add it as a fixed course:

route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1

With this, 10.0.0 .1 will certainly be your default portal and also eth1 will certainly be made use of just to connect to 192.168.2.0 network

4
2022-06-07 15:41:38
Source