LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to enable ping by non-root on non-main routing tables? (http://www.linuxquestions.org/questions/linux-networking-3/how-to-enable-ping-by-non-root-on-non-main-routing-tables-4175421058/)

donalbane 08-08-2012 02:08 PM

How to enable ping by non-root on non-main routing tables?
 
I have no default route in the main routing table. I have a separate routing table created for each cellular provider that I use with the default route assigned there. I notice that if I try to execute ping through a specific interface (i.e. "ping -I ppp0 8.8.8.8") as a non-root user, that it attempts to use the main routing table (which then fails with "Network Unreachable"). However, if I run "sudo ping -I ppp0 8.8.8.8", it will correctly use the appropriate default gateway in the provider-specific routing table and work fine.

Can someone tell why the ping uses correct routing table for root, but ping for a non-root user does not?

Thank you,
Don

ProtoformX 08-09-2012 10:56 AM

This is a fairly simple explanation actually,
The user can't touch hardware interfaces (eth0, ppp0..etc) are hardware nodes so of course ping -I ppp0 as a user will fail, you don't have the right to access that interface.

So ping just tries to get out whatever interface is available. (if ppp0 is indeed configured and working then if you wanted to ping through ppp0 try changing the metrics of both interfaces so that ping looks at ppp0 first and not eth0.

donalbane 08-09-2012 11:48 AM

Thanks, ProtoformX, for the explanation.

However, I don't think that changing the metrics on the interfaces will solve the problem. If ping DID look for any route available, then "ping 8.8.8.8" would work for the general user when ppp0 is the only interface available. However, that does not happen unless there is a default route through ppp0 in the main routing table. I don't want to have to reconfigure the main routing table everytime the user wants to ping out a particular interface.

Does this mean there isn't a way for a general user to specify the interface to be used?

Don

ProtoformX 08-09-2012 12:52 PM

There is, you need to give them permission to the interface (maybe as part of a group?) but no not directly.

donalbane 08-09-2012 03:31 PM

This post

http://serverfault.com/questions/406...r-an-interface

indicates that ping should run as root, if owned by root (mine is). That would seem to make the use of sudo irrelevant, but it's not in my case.

I also looked at the ownership/permissions of the devices that the interfaces are being created on. The devices are created as
crw-rw-rw- root:dialout /dev/ttyUSB#
and the symlinks created for them from the udev rules show up as
lrwxrwxrwx root:root /dev/USBModem#

All users are part of the dialout group. I'm using the symlinks for pppd, but my understanding is that they are passthrough for permissions to the actual devices, so I wouldn't think that root being the group for the symlinks would matter. Strangely, changing the GROUP or MODE in the udev rules has no effect on the group/permissions of the symlinks.

Don

donalbane 08-15-2012 02:11 PM

I've discovered that a non-root user can successfully do:

ping -I <IPaddress> 8.8.8.8

while

ping -I <interface> 8.8.8.8

fails.

So, it doesn't seem to be a permissions issue, but rather something is wrong in the routing table configuration that prevents the interface name from properly being associated with its IP address for non-root users.

Can anyone give me a simple routing table setup procedure for 2 interfaces that will allow "ping -I <interface> 8.8.8.8" to work properly for each interface for a non-root user?

Don


All times are GMT -5. The time now is 05:10 PM.