Saturday, October 18, 2014

EXP 12: add static route on linux network

Problem
Connect both wired and wifi network.

Wired for LAN and wifi for internet.

Connected to LAN but can not connect internet.

Cause
On console, type

route

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 9.9.9.1 0.0.0.0 UG 0 0 0 eth0
9.9.9.0 * 255.255.255.0 U 1 0 0 eth0
10.0.0.0 * 255.0.0.0 U 2 0 0 wlan0
link-local * 255.255.0.0 U 1000 0 0 eth0

default gateway using eth0, ip 9.9.9.1, so you can not connect internet with this.

Solution
Change default gateway from eth0 to wlan0 using static route

sudo route add -net default gw 10.128.128.128 netmask 0.0.0.0 dev wlan0 metric 0

sudo route del -net default gw 9.9.9.1 netmask 0.0.0.0 dev eth0 metric 0

No comments:

Post a Comment