Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i need your help on this. been trying to figure out how to make this work for hours! my network skills are a bit rusty.

alright, i have 2 interface, and i want to create a static route for each.

10.10.10.0/24 gw 10.10.10.1

10.167.95.0/26 gw 10.167.95.1

auto eth0
iface eth0 inet static
    address 10.167.95.25
    netmask 255.255.255.192
    gateway 10.167.95.1

auto eth1
iface eth1 inet static
    address 10.10.10.100
    netmask 255.255.255.0
    gateway 10.10.10.1

how can i create this kind of route:

all 0.0.0.0 -> 10.167.95.1 interface

and for 10.0.0.0 -> 10.10.10.1 interface


[EDIT]

this is my current route -n

dest         gw         mask      flags     metric      ref     use    iface
0.0.0.0  10.167.95.1   0.0.0.0     UG          0         0       0     eth0

when i execute this

route add -net 10.0.0.0/24 dev eth1

my 10.167.95.0/26 drops, while my 10.0.0.0/24 turns okay. unless i remove the latter, 10.167.95.0/26 returns RTO.


[EDIT #2]

    dest         gw            mask           flags     metric      ref     use    iface
   0.0.0.0      10.167.95.1   0.0.0.0          UG        100         0       0     eth0
   10.0.0.0     0.0.0.0       255.255.255.0    U          0          0       0     eth1
   10.167.95.0  0.0.0.0       255.255.255.192  U          0          0       0     eth0


eth0      Link encap:Ethernet  HWaddr 00:0c:29:a8:ec:00  
          inet addr:10.167.95.25  Bcast:10.167.95.63  Mask:255.255.255.192
          inet6 addr: fe80::20c:29ff:fea8:ec00/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3642 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2292 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:340931 (340.9 KB)  TX bytes:249696 (249.6 KB)
          Interrupt:18 Base address:0x2000 

eth1      Link encap:Ethernet  HWaddr 00:0c:29:a8:ec:0a  
          inet addr:10.10.10.100  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fea8:ec0a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2215 errors:0 dropped:0 overruns:0 frame:0
          TX packets:466 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:151858 (151.8 KB)  TX bytes:30828 (30.8 KB)
          Interrupt:16 Base address:0x2080 

after setting up route table above, and restart network /etc/init.d/networking restart i get this

RTNETLINK answers: File exists
Failed to bring up eth1.

[EDIT #3]

Currently my route table

 dest         gw            mask           flags     metric      ref     use    iface
0.0.0.0      10.167.95.1   0.0.0.0          UG        100         0       0     eth0
10.167.95.0  0.0.0.0       255.255.255.192  U          0          0       0     eth0

10.167.95.25 is reacheable

i want to add route for 10.10.10.0/24, so i executed this command as suggested

route add -net 10.10.10.0/24 dev eth1

routing table modified as below

 dest         gw            mask           flags     metric      ref     use    iface
0.0.0.0      10.167.95.1   0.0.0.0          UG        100         0       0     eth0
10.10.10.0   0.0.0.0       255.255.255.0    U          0          0       0     eth1
10.167.95.0  0.0.0.0       255.255.255.192  U          0          0       0     eth0

10.167.95.25 is not reacheable

10.10.10.100 is recheable

share|improve this question
add comment

1 Answer 1

It is moderately easy

 sudo route add default gw 10.167.95.1
 sudo route add -net 10.167.95.0/26 dev eth0
 sudo route add -net 10.10.10.0/24  dev eth1 

In these three commands, the first one introduces a default gateway, the other two make explicit which interface to use to contact your two LANs.

I see no reason for commenting out the gateway in the stanza for eth0, even though I do not think it hurts either.

share|improve this answer
    
hi there. can you kindly look at my edit, i cant seem to make it work. –  user1735120 Nov 26 '13 at 5:46
    
@user1735120 insert the statements network 10.0.0.0 and network 10.167.95.0 in the appropriate stanzas in /etc/network/interfaces, restart networking, try fixing the routing table again, if it does not work please post the output of ifconfig -a –  MariusMatutiae Nov 26 '13 at 5:56
    
hi @MariusMatutiae, kindly see edit 2, i have attached ifconfig and also added network statements in my /etc/network/interfaces –  user1735120 Nov 26 '13 at 9:00
    
@user1735120 First error message nothing to worry about. However, I made a mistake in suggesting the route. Please check my corrected answer (the part sudo route ...) , then turn off and then on pc, insert new routes, it should work. My mistake, sorry. –  MariusMatutiae Nov 26 '13 at 9:08
    
hi sir, i really appreciate your patience in helping me. kindly see edit 3, i have executed your suggestion but i cant make 2 interface work. please verify my route table. –  user1735120 Nov 26 '13 at 9:43
show 5 more comments

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.