How to enable ping by non-root on non-main routing tables?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
Last edited by ProtoformX; 08-09-2012 at 10:58 AM.
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?
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.
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.