Linux: Setup static routes

From Define Wiki
Revision as of 11:41, 4 October 2012 by David (talk | contribs) (Created page with "Force traffic out on eth1 instead of eth0 (def gw), even though IP of system i'm accessing out on eth1 falls within the eth0 subnet * Route tables before <syntaxhighlight> [root@mgmt001...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Force traffic out on eth1 instead of eth0 (def gw), even though IP of system i'm accessing out on eth1 falls within the eth0 subnet

  • Route tables before
[root@mgmt001 ~]# route -n 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.31.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0
172.31.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 ib0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
192.168.0.0     0.0.0.0         255.255.0.0     U     0      0        0 ib0
239.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 ib0
0.0.0.0         172.31.4.1      0.0.0.0         UG    0      0        0 eth0


  • Add static route
  route add -net 172.31.3.0 netmask 255.255.255.0 dev eth1
  • Route tables afterwards
[root@mgmt001 ~]# route -n 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.31.3.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1 ###########################
172.31.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0
172.31.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 ib0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
192.168.0.0     0.0.0.0         255.255.0.0     U     0      0        0 ib0
239.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 ib0
0.0.0.0         172.31.4.1      0.0.0.0         UG    0      0        0 eth0
  • Add a default gateway
  route add default gw 192.168.1.254 eth0
  • Add a route to another network (e.g. rocks headnode to access ipmi modules from local host)