LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 12-25-2012, 03:39 AM   #1
Tekiano
LQ Newbie
 
Registered: Nov 2012
Posts: 12

Rep: Reputation: Disabled
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
ifconfig: SIOCSIFMETRIC: Operation not supported

ifconfig ppp0 metric 10
ifconfig: SIOCSIFMETRIC: Operation not supported


$route 
default       *               0.0.0.0         U     0      0        0 ppp0
X.X.X.0       *               255.255.255.255 UH    0      0        0 ppp0
192.168.1.0   *               255.255.255.0   U     0      0        0 wlan0
could you please tell me how to configure this using the metric, and is it the best way to do it ?

Thank you
 
Old 12-25-2012, 08:03 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 1,999

Rep: Reputation: Disabled
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
Or you can use the route command:
Code:
route add -net 0.0.0.0 netmask 0.0.0.0 metric 50 dev ppp0
If the wlan0 interface gets an address and gateway via DHCP and the metric value is lower then the one specified for the default route via ppp0, the former will take precedence.
 
Old 12-26-2012, 04:10 AM   #3
Tekiano
LQ Newbie
 
Registered: Nov 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thanks for your reply,
I tried your command, here the results :

Code:
$ip route add 0.0.0.0/0 dev ppp0 metric 50
$route
default         *               0.0.0.0         U     0      0        0 ppp0
default         *               0.0.0.0         U     50     0        0 ppp0
10.25.25.25     *               255.255.255.255 UH    0      0        0 ppp0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
192.168.253.0   *               255.255.255.0   U     0      0        0 tap0
192.168.254.0   *               255.255.255.0   U     0      0        0 wlan0

$traceroute www.google.com
traceroute to www.google.com (173.194.70.147), 30 hops max, 38 byte packets
 1  10.203.11.14 (10.203.11.14)  67.985 ms  59.632 ms  49.820 ms
....
I see that even if wlan0 is connected to internet the route is throw ppp,
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 ?
 
Old 12-26-2012, 04:46 AM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 1,999

Rep: Reputation: Disabled
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?
 
Old 12-26-2012, 04:54 AM   #5
Tekiano
LQ Newbie
 
Registered: Nov 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
I just use the followin command :
Code:
pppd call ppconfig
and then the interface ppp0 is up automatically

after that I launch openvpn to establish the tunnel.
 
Old 12-26-2012, 05:10 AM   #6
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 1,999

Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Change the default interface in CFEngine configuration lulu_go Linux - Server 1 07-05-2011 10:57 AM
Tricky debugging problem - threads + dynamically linked driver with fixed interface matthewg42 Programming 0 03-25-2011 03:28 PM
change grub boot order, all instructions say change default, but I don't see default mhg Linux - Newbie 5 11-09-2008 10:01 AM
Dynamically change ip address on boot up carolw Linux - Newbie 2 08-05-2003 02:08 AM
change partition size dynamically kodiakmook Linux - General 3 01-07-2002 02:56 PM


All times are GMT -5. The time now is 04:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration