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.
I leave my computer running nonstop. Every few months it loses its connection. I get my IP through DHCP and have no control over the DHCP server. My IP never changes even though it is dynamic.
I would like to do something to ensure that the computer puts itself back online.
Would a cron job be a good idea? I could have it check the network status every hour, and do a 'service network restart' (or equivalent) if it is offline.
Could you tell me if this is the correct solution, and if so, exactly what commands would I put in the cron job?
When the machine is offline doing 'service network status' returns: configured currently active lo eth0.
I'm sure that you could create a script to check the output from somthign like:
ping -c 3 ip.of.your.gateway | grep -c "bytes from"
If the outut is 3 then the connection is OK - 0 then the system cannot reach your gateway and in the middle if there are intermittent network problems.
Although your IP is assigned by DHCP - have you tried configuring for a static IP (using the same details that DHCP gives)?
Originally posted by david_ross I'm sure that you could create a script to check the output from somthign like:
ping -c 3 ip.of.your.gateway | grep -c "bytes from"
If the outut is 3 then the connection is OK - 0 then the system cannot reach your gateway and in the middle if there are intermittent network problems.
Although your IP is assigned by DHCP - have you tried configuring for a static IP (using the same details that DHCP gives)?
Interesting, thanks. Is "service network restart" the right command for getting the connection back? I'll start writing a script.
I'm not quite sure what you mean configuring for a static IP. What benefits would that offer?
PS - Sorry for the late reply, I was gone fishin' as they say.
Originally posted by david_ross "service network restart" should reset the connection for you.
If your IP never changes then you may be able to just specify the IP, netmask and gateway - this should solve the problem if it is a dhcp issue.
thats funny.... i just installed slackware 10 and i'm using the 2.4.26 kernal and under mandrake i could always go "service network restart" if i needed to, however i just tried to use it here and it didn't know what i was talking about.
is "service network restart" a linux thing or a mandrake thing? having to reboot my linux system to get on the internet is NOT cool....
Hey I'm running into the same problem but we have a unique instance where as the linux server (RedHat) is running as a Microsoft Virtual Server. Is there anyway you can post the shell script.
I am unable to ping the box yet doing "service network restart" successfully shuts down the network interface and brings them back up and everything seems towork fine again for awhile. (Any Suggestions? )
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.