Change dynamically internet default interface
Hi,
I use my pc as a router for other equipments, I have these interfaces that can connect my pc to internet : ppp0 and wlan0, so I want that the system routes internet packets throw wlan0 when wlan connection is available otherwise via ppp0, I tried to configure this using metric settings but it failed : Code:
ifconfig wlan0 metric 1 Thank you |
A metric is associated with a route, not an interface. You can add a default route using the ip route command:
Code:
ip route add 0.0.0.0/0 dev ppp0 metric 50 Code:
route add -net 0.0.0.0 netmask 0.0.0.0 metric 50 dev ppp0 |
Thanks for your reply,
I tried your command, here the results : Code:
$ip route add 0.0.0.0/0 dev ppp0 metric 50 I need that connection to internet must be through wlan, and I also need to keep my vpn connection that was established through ppp0 Does any one have an idea how to do this ? |
As you can see, you still have a default route through ppp0 with a metric of 0 in addition to the route you added manually. Also, you don't actually have a default route through a gateway on the wlan0 network.
The default route through ppp0 is probably added by a connection script. Exactly how do you activate the ppp0 connection? |
I just use the followin command :
Code:
pppd call ppconfig after that I launch openvpn to establish the tunnel. |
You should find a configuration file called "ppconfig" in /etc/ppp/peers/. It should contain the keyword "defaultroute", which causes pppd to create a default route with a metric of 0. You will need to remove or modify that route.
The ideal solution would be to have pppd create a default route with a higher metric. There was a proposed patch to pppd which added a "defaultroute-metric" option, but I don't think it was ever accepted into the official pppd project. You could change the "defaultroute" option to "nodefaultroute" and add an "ip route add" command to /etc/ppp/ip-up, or you could leave "defaultroute" and use "ip route change" in /etc/ppp/ip-up instead. Of course, none of this will make any difference as long as you don't have an alternative default route through the wlan0 network. |
All times are GMT -5. The time now is 04:19 PM. |