LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-03-2009, 04:30 PM   #1
Yves Plasse
LQ Newbie
 
Registered: Jan 2009
Posts: 5

Rep: Reputation: 0
eth0 and ppp0


I am using Slackware 12.2 and I am currently having a network problem. Most of the time, I use the ethernet link eth0. However, I also want to use PPP on dialup to reach some other networks.

I created an account on KPPP and it does connect properly. The only way I found to have the network recognised on my Linux machine is to disable the ethernet link (eth0) using the network configuration application on KDE before dialing. This way, the ppp0 device is then acessible and I am able to ping and telnet whre I need.

I don't mind not using my ethernet link when I dial to a PPP host. I find it strange to have to disable the ethernet device eth0 before dialing. Is there a way to have this done automatically. Is there a special configuration to set when eth0 and ppp0 is to be used on the same Linux machine?

Thank you,
YVes Plasse.
 
Old 01-03-2009, 11:35 PM   #2
anotherlinuxuser
Member
 
Registered: Jan 2007
Location: Alberta Canada
Distribution: Fedora/Redhat/CentOS
Posts: 68

Rep: Reputation: 19
The problem is likely routing related. The default route will be using eth0, so even though the ppp link is up, unless you specify routes to the network(s) on the far end of the ppp link, all traffic, except for addresses on the same lan as the ppp link, will continue to go through the eth0 interface.

The reason it works when you stop eth0 before starting the ppp link, is that the ppp link becomes the default route as that is the only available link, so all traffic goes through the ppp link.

(The IP addresses you see will not likely be the same as these examples)
For example, with the ppp link down, 'netstat -rn' will display something like:
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0

The last line, that starts with 0.0.0.0, is the default route. Any destination IP that does not match an earlier
route, will go through eth0.

After starting the ppp link, without adding any extra routes, the route table will look something like this:
Destination Gateway Genmask Flags MSS Window irtt Iface
10.42.49.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0

Note the new route for Iface ppp0.
The new route, that starts with 10.42.49.1, was added because that is the LAN of the ppp link. However, as the
route table is now, only destinations of 10.42.49.nnn will go through the ppp link.

To add a route to a LAN on the far side of the ppp link, use a command similar to this:
route add -net 172.17.1.0/24 ppp0

Now the netstat -rn will produce:
Destination Gateway Genmask Flags Metric Ref Use Iface
10.42.49.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.17.1.0 0.0.0.0 255.255.255.0 U 0 0 0 ppp0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0

Note the new route to 172.17.1.0.
So now a ping, telnet, etc to any 172.17.1.nnn address will go thru the ppp0 link. Requests to all other
addresses will still go thru the eth0 link, as it is still the default.

I do not use KPPP, but most PPP frontends will allow you to specify LAN addresses that are on the far side of each
defined ppp link. If KPPP allows you enter LAN Addresses somewhere in the ppp link config, then KPPP will
automatically add/remove the routes when it starts/stops the ppp link.
 
Old 01-04-2009, 03:02 PM   #3
Yves Plasse
LQ Newbie
 
Registered: Jan 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Your solution works great when I am logged as root. I can also automate the 'route' command with a script that would be executed after the connection to the host.

I tried the same thing while being logged as a user and the 'route' command does not seem to be available on the Korn shell (ksh). Is there a way to have the same functionnality without being logged as root?

Thank you,
Yves Plasse.
 
Old 01-04-2009, 11:48 PM   #4
anotherlinuxuser
Member
 
Registered: Jan 2007
Location: Alberta Canada
Distribution: Fedora/Redhat/CentOS
Posts: 68

Rep: Reputation: 19
You are correct, the route command is normally a root only command. You could add /sbin/route to the /etc/sudoers file to allow regular users to add/remove routes. For this solution add a line like this to /etc/sudoers:

%user ALL= NOPASSWD: /sbin/route

Where 'user' would be set to either a username (allow only specified users to use route), or 'user' can be a group name to allow multiple users to use the route command.

Then you can create short script(s) to add the route(s).

Another option is to add the required route commands to the
/etc/ppp/ip-up.local script. On most distros, this script is run by the pppd program as part of the starting of links, if it exists and has execute permissions. This method has a security advantage over the sudoers method, but requires scripting knowledge and testing to make it work.
The ip-up.local script will receive args from pppd that can be
used determine what routes to add/remove for any given destination. The script will be called by root, since kppp will be running as root.

Last edited by anotherlinuxuser; 01-04-2009 at 11:59 PM.
 
  


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
eth0+ppp0 routing kwlg Linux - Networking 5 07-18-2005 05:50 PM
ETH0 and PPP0 interaction ? drakeman Linux - Networking 7 12-29-2004 02:37 PM
Masquerading ppp0 and eth0 zulfilee Linux - Networking 2 07-20-2004 12:32 AM
ppp0 uses eth0... but eth0 never activates joshuapurcell Linux - Networking 3 12-17-2003 12:52 AM
eth0 eth1 ppp0 janisj Linux - Networking 2 07-06-2003 01:55 PM


All times are GMT -5. The time now is 12:44 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration