On Linux, how do I change the default route?
Nov 03, 2020
asked by anonymous
Question / Issue:
I have the following route table but want the default traffic to go out eth0. How do I change this?
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.3.1 0.0.0.0 UG 0 0 0 eth2
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
192.168.3.0 * 255.255.255.0 U 0 0 0 eth2
192.168.5.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.6.0 * 255.255.255.0 U 0 0 0 eth1
Responses:
Date: Nov. 3, 2020
Author: Mind Chasers
Comment:
Assuming your gateway on eth0 is 192.168.0.1, try this:
# ip route replace default via 192.168.0.1
Your routing table should look like something like this:
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
192.168.3.0 * 255.255.255.0 U 0 0 0 eth2
192.168.5.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.6.0 * 255.255.255.0 U 0 0 0 eth1