LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Problem with 'route' on temporary dialup connection (https://www.linuxquestions.org/questions/linux-networking-3/problem-with-route-on-temporary-dialup-connection-559860/)

Gethyn 06-07-2007 04:54 AM

Problem with 'route' on temporary dialup connection
 
Hi there, normally I access the internet via ADSL. Due to a mixup by my ISP, broadband has been cut off, and while I'm waiting for it to be restored they've provided a free dialup connection. I managed to get the dialup modem working (which was a saga in itself), but there is a complication: since the computer the modem is in is normally on a LAN and connects via an external modem router, the default route is through the ethernet connection gateway. This means that when I connect via dialup, networking programs are unable to find their way out of the local net.

To fix the problem, after the connection is established, I run 'route add default ppp0' to add the dialup connection as the default for IP connections. This works fine for me, but the computer has a number of other users. A lot of these people are non tech-savvy and consequently don't know how to use the command line, and don't have access to root privileges (I'm using Ubuntu so this is done via sudo).

Since the net interface ppp0 doesn't exist until the dialup connection is established, I can't just put the command 'route add default ppp0' in the boot sequence. I'm not willing to make the boot sequence open the dialup connection automatically (and then fix the route), because doing so obviously ties up the phone line, which is needed for calls (not to mention problems with making sure the connection is established before setting the route)!

In order to make it possible for other people to use the dialup, I tried making a script, which looked like this:
Code:

#!/bin/sh
route add default ppp0

I set the owner of the script to root, and turned on the sticky bit, which I *thought* would enable the script to be run by other users, while taking on root privileges, therefore allowing the command to run. However, when I try running this script I get a "SIOCADDRT: Operation not permitted" error, the same as if an unprivileged user tries to run route.

I guess one way of getting round the problem would be to temporarily set the sticky bit on route (right?), but there must be a more elegant way. Can anyone suggest one?

This problem isn't massively important, broadband should be back in a few days, but it would stop people bugging me about it, and also I'm always keen to learn more about what I'm doing...

Thanks!

KenJackson 06-07-2007 07:00 AM

It's not the sticky bit you are thinking of, but the setuid bit, which would cause the script to run with the permissions of root. But setting that bit should only be done as a last resort, especially on a script.

I'm not sure about Ubuntu, but Mandriva starts up PPP with the script /etc/sysconfig/network-scripts/ifup-ppp.

When the connection is made, the default route is automatically added unless there is a line in the file /etc/sysconfig/network-scripts/ifcfg-ppp0. The line is "DEFROUTE=no".

If you find the equivalent Ubuntu file and that line is present, delete or comment it and the default should be automatically added when the connection is established. And the old default will be restored when the connection is torn down.

If that doesn't work, trace backwards from system script /sbin/ifup to find a place to add a local configuration line.

Gethyn 06-07-2007 08:04 AM

Hi Ken, thanks for that. Not sure why I said the sticky bit, since it was definitely the setuid bit that was set (chmod 4755 script_name). It turns out that Ubuntu ignores the setuid bit on scripts for security reasons, which would explain why my script didn't work. After some hunting around, I think that editing /etc/ppp/peers/<connection_name> to include the options "defaultroute" and "replacedefaultroute" should fix things. At the moment I'm at work, not at home, so can't test it, but when I get back later I'll have a go and report back. Thanks for your hints so far!

Gethyn 06-11-2007 08:46 AM

Just in case this helps other people in future: I connected using kppp. Adding the lines 'defaultroute' and 'replacedefaultroute' to the file /etc/ppp/peers/kppp-options fixed the problem. If you use a different program such as wvdial or gnome-ppp, you'd need to add the options to a different file, but they all seem to be kept in /etc/ppp/peers.


All times are GMT -5. The time now is 02:54 PM.