Search:

PmWiki

pmwiki.org

edit SideBar

Main / Route

route -n gives you better looking information.

Default Gateway

route add default gw <IP> <if-name>
route add -net <IP> netmask <netmask> <if-name>
In order for internet packets to be directed out of a given interface, the route table must be set up like this (.1 is a common final octet for gateways):

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.20.30.1       0.0.0.0         UG    0      0        0 eth1


For example, if all you have is this entry
10.20.30.0       0.0.0.0         255.255.254.0   U     0      0        0 eth1

that won't work.

Note that if you have more than one gateway set in your interfaces config, you'll get an error saying

RTNETLINK answers: File exists
Failed to bring up eth1.

Another way to mess with default routes is ip route del default via 192.168.0.1 for example. This is handy when you get a machine that keeps creating a second default gateway for a nonsense port that screws up your internet access. I have seen stupid problems like "Unknown host" when trying the tradition route del default command, but the above works.

Here's the route alternative to deleting: sudo route del -net 0.0.0.0 gw 0.0.0.0 dev <ethifname>


Page last modified on June 08, 2020, at 11:36 PM