Cannot contact external hosts, route resets after setting gateway
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.
Cannot contact external hosts, route resets after setting gateway
Ok, I have an old Linux box, which is just serving as a mail server on a private LAN, but for some reason, it is unable to contact hosts from outside the LAN. I think that it is a routing issue. The gateway that it should be using is located at 192.168.10.101, but it is not using it. That would be a simple problem, but when I use 'route' to register the gateway, the new entry in the routing tables only sticks for around 15 seconds. Demo:
Code:
[root@lcmme /root]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.0.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
[root@lcmme /root]# ping google.com
connect: Network is unreachable
[root@lcmme /root]# route add default gw 192.168.10.101
[root@lcmme /root]# ping google.com
PING google.com (64.233.167.99) from 192.168.10.103 : 56(84) bytes of data.
64 bytes from 64.233.167.99: icmp_seq=0 ttl=240 time=90.177 msec
64 bytes from 64.233.167.99: icmp_seq=1 ttl=240 time=89.326 msec
64 bytes from 64.233.167.99: icmp_seq=2 ttl=240 time=89.127 msec
ping: sendto: Network is unreachable
ping: wrote google.com 64 chars, ret=-1
ping: sendto: Network is unreachable
ping: wrote google.com 64 chars, ret=-1
ping: sendto: Network is unreachable
ping: wrote google.com 64 chars, ret=-1
So, it knows how to get to the LAN, that is the first line of route. It knows how to get to itself, that is the second line of route. When I add the gateway to get to the WAN, I am able to contact external hosts. But it only lasts for a brief moment. The ping works, then dies part way through.
Does anybody have any ideas why this might be happening?
It is a terribly terribly old RH7 box. Shaddup. Don't even start. I would upgrade it if I could, but I can't bring it down. It is running a 2.2 kernel. Trust me when I say I know how much that sucks.
Yes it is a single interface. There is only one physical device, and it is set as eth0.
I would not know what config files to edit, or what the syntax for them should be. Shouldn't the command line tools change the config files for me?
It is a terribly terribly old RH7 box. Shaddup. Don't even start. I would upgrade it if I could, but I can't bring it down. It is running a 2.2 kernel. Trust me when I say I know how much that sucks.
Yes it is a single interface. There is only one physical device, and it is set as eth0.
I would not know what config files to edit, or what the syntax for them should be. Shouldn't the command line tools change the config files for me?
To answer your question - no, the commnd line stuff does not change files. It only changes setting for the current session. If you were to reboot the computer or restart the network, settings will be gathered from the files & the changes you made at the command line would be lost.
Man, I just brought down my last RH7 box about a month ago. I believe the files are located in /etc/sysconfig/network (just like the more recent Red Hats & Fedoras). there's probably something called ifup.eth0 (or something like that) in there that has all that you need.
All that said, what you're doing, albeit the hard way, does not seem to be wrong. There may be other problems at play here.
If I were you, I'd try to find those files, see what they contain, they try restarting the network through init.d.... i.e. as root, run "/etc/init.d/network restart" (where 'network' is the name of the network startup script - it may not be called network, but it will exist in /etc/init.d).
The only config file with any relevance to routing I have been able to find is "/etc/static-routes", and it is completely empty. There are many config files in /etc/sysconfig/networking, but a quick grep shows that none of them make any mention of "route", "gateway", or "ARP" (Case insensitive, all). Affecting the one session should be enough though. If I could even just reboot that sucker, it would have a new kernel two stable Y versions newer. It is strange that the routing table will reset in the middle of the ping. I find that very odd. It only lasts for a seemingly arbitrary (short) amount of time, then resets. Nobody knows why that might be happening?
[Edit]
Not sure if this will actually help, but just noticed you're routing table says you're on class B network 192.168.0.0. Is this correct for your setup? Or should the machine be on the class C 192.168.10.0 network?
[/EDIT]
EXAMPLES
...
route add default gw mango-gw
adds a default route (which will be used if no other route matches). All packets using this route
will be gatewayed through "mango-gw".
I am sure the fact that it is not a named host has nothing to do with it.
I have solved this problem, though I still do not understand it, by using the Redhat 'netcfg' GUI to add a gateway route. It seems to have changed the /etc/sysconfig/static-routes file. I was looking at editing that file manually earlier, but I could not find any explanations of the syntax of it. This is the line it added:
Code:
eth0 net default netmask 0.0.0.0 gw 192.168.10.101
It may have also made other changes, but if it did, I do not know about them.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.