[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: preferring wired over wireless



Le 13092ième jour après Epoch,
Luca Pireddu écrivait:

> When both my wireless and wired networking devices are connected, how can I 
> get my laptop to use the wired device and ignore the wireless one?  I tried 
> specifying a higher metric for my wired device (via ifconfig metric), but it 
> doesn't seem to have an effect.

If both interfaces are on same network, metric can't help you... You
must use "ip rule" and "ip route" without default route to solve your
problem.

man ip

and contact me (us) again if you have problems.

For example:

# eth1 = wired
# eth2 = wireless

/sbin/ip rule add prio 50 table main
/sbin/ip route del default table main

/sbin/ip rule add prio 201 from <wired_ip>/32 table 201
/sbin/ip route add default via <wired_gateway> dev eth1 src <wired_ip> proto static table 201
/sbin/ip route append prohibit default table 201 metric 1 proto static

/sbin/ip rule add prio 202 from <wireless_ip>/32 table 202
/sbin/ip route add default via <wireless_gateway> dev eth2 src <wireless_ip> proto static table 202
/sbin/ip route append prohibit default table 202 metric 1 proto static

/sbin/ip rule add prio 222 table 222
/sbin/ip route add default table 222 proto static nexthop via <wired_gateway> dev eth1 weight 2 nexthop via <wireless_gateway> dev eth2 weight 1

-- 
Un groupe de loups, c'est une horde. Un groupe de vaches, c'est un
troupeau. Un groupe d'hommes, c'est souvent une bande de cons.
	-+- Philippe Geluck, Le chat -+-



Reply to: