Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have one two interfaces on one machine, one is the Internet connection that get its IP from a DHCP, no problem.

The other interface (eth1) is to local machines, and it has the gateway 192.168.3.1 is set in its configuration file (Ubuntu based distro).

The problem is, that when i am bring the eth1 interface up, it automatically add a default (0.0.0.0) route to the route table (as it should do), and i can't connect to the Internet, since it try to send the packets to the local network. Until now i have had to do it manually by deleting the default route with the 192.168.3.1 gateway.

Is there a way to set that it wouldn't add a default route once i bring up the interface ? I am still need the gateway 192.168.3.1 to stay in the configuration file since i have to have some specific route to the 3.x network.

Here is my route table:

192.168.3.0     *               255.255.255.0   U     0      0        0 eth1
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
default         192.168.3.1     0.0.0.0         UG    100    0        0 eth1
default         DD-WRT          0.0.0.0         UG    100    0        0 eth0
share|improve this question

2 Answers 2

up vote 2 down vote accepted

Don't declare 192.168.3.1 as a gateway. Gateway pretty much means “default route”. If the address of the interface is within the 192.168.3.1/24 network, then netmask 255.255.255.0 is all you need.

If that's not the case, add whatever route you need as part of the interface setup script. On Debian/Ubuntu, put an up clause in /etc/network/interfaces, or add a script in /etc/network/if-up.d. The command to run is route add 192.168.3.1 eth1 && route add -net 192.168.3.0/24 gw 192.168.3.1

share|improve this answer
    
commented the gateway clause in the /etc/network/interfaces/ under the problem maker interface, and it worked. –  Hanan N. Dec 18 '11 at 0:01

Do a ip route list first and then check the same again on eth1 interface. Put the same thing into /etc/sysconfig/network-scripts/route-eth1 file to make everytime the interface is restarted, the route configuration from the interface file to be applied. On the other hand, if you want to execute something specifically for it, you could put in /etc/rc.d/init.dnetwork script to do it for you everytime the network is restarted, it would as well read the route-eth1 file and apply the route configuration.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.