Find the answer to your Linux question:
Results 1 to 8 of 8
Hello, I'm new to the forums. I'm sorry if this is the wrong section but i have an issue and i was wondering if you could help me out. Basically ...
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    2

    Unhappy Centos Problem (Network)

    Hello, I'm new to the forums.

    I'm sorry if this is the wrong section but i have an issue and i was wondering if you could help me out.

    Basically i have an 1 socket server with external battery connections. well basically the problem is whenever there is power cuts in my area it will disconnect the hole network everything totally accept the server as it's on a external battery pack which leaves the server running for a few hours. My problem is once all the power comes back on the server will remain as normal with the Ethernet from the server direct to modem. all the network will come back on (Internet etc..) as everything is in normally the only problem is whenever my users visits the website which the server is run by it wont allow them to connect it will say connection timed out or server taking too long to respond etc..

    Even though the internet is on and everything is perfect just how it was before the power cuts. The way i fix this is too just too deactivate eth0 and re-active eth0 again.. that's all i do and the website will be back-up as normal.

    Do any of you know how i can make it so it does this automaticlly? instead of my going to the server etc.. just to de-active eth0 and re-activating it. Because where i live you do get power cuts quite often and the server is down a lot just because it wont allow my users to connect.. even though everything is connected.

    everytime there is a powercut it disconnects my network but leaves my server running as normal once power comes back on network will re-connect internet etc.. will be back on as normal.. but wont allow people to connect to the server until i go to the server my self and open the network manager select de-actvate eth0 and re-active it.. then it will be back as normal..

    I want it to do it automatically instead of me going to the server all the time doing this my self. Is it possible? because sometimes we will have powercut around here at like 6 am and i wont be up til like 11 am, for an example and thats 5 hours downtime for people.. which is anoyying.

    please can anyone help me solve this?

    Hope you understand what i mean, Very confusing..

    Thank you.

  2. #2
    Linux Newbie Ziplock's Avatar
    Join Date
    Jan 2009
    Location
    Adelaide
    Posts
    169
    Hi Danzy,

    It sounds to me like eth0 is not renegotiating the link when the modem power comes on again.

    Is there anything in /var/log/messages for eth0 if you power cycle the modem?
    Does 'ifconfig eth0' indicate the the link is 'up' after a power failure?
    Does the modem act as a DHCP server? If so, can you assign a static ip address?

    Cheers,

    Ziplock

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Posts
    2
    Hi,

    Nothing in messeges,
    ---------------
    ifconfig eth0, says it's up:

    Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    ---------------

    The modem gets a static ip from the ISP you cannot set it you're self.

    I noticed when the power goes there is no internet actually. What i need to do is to get everything back on is go to the network configuration, System > Administration > Network. then in the devices where eth0 is it will say it's active so i de-active it and re-active it and it just gets the IP from the modem and everything is perfect again..

    Seems i need to de-active and re-active just to get everything running again.. is there any way to do this automatically? just incase im not around ..

    The modem does not give out new ip's it's just 1 static ip and has been for the last year.

    Any help would be much appreciated, Thank you.

    Danzy,

  4. #4
    Linux Newbie Ziplock's Avatar
    Join Date
    Jan 2009
    Location
    Adelaide
    Posts
    169
    Hi,

    My way of solving this would be to write a quick script to ping a known host a couple of times, then, if the host doesn't respond, restart eth0

    I would pick a host from your ISP network, which I would get from a traceroute google.com

    The script would look something like this:

    Code:
    #!/bin/bash
    
    if [[ `ping -c 3 <host> | grep "100% packet"` ]]; then
      /etc/sysconfig/network-scripts/ifdown eth0;
      /etc/sysconfig/network-scripts/ifup eth0;
    fi
    I would then run this script every 5 minutes from cron as root.

    If the power goes off, you have to wait 5 minutes at the most to get connection back. Adjust time between runs accordingly.

    Cheers,

    Ziplock

  5. #5
    Linux Newbie
    Join Date
    Sep 2005
    Location
    CZ
    Posts
    164

    Exclamation

    Wouldn't it result in a "bad" connection for the end users? Let's consider someone that would download something big and just before his download completes, the networking will be reset. (If < 100%, that is...) What would happen? I'd say: "His download is lost?"

  6. #6
    Linux Newbie Ziplock's Avatar
    Join Date
    Jan 2009
    Location
    Adelaide
    Posts
    169
    No, this script would only reset the connect if ALL 3 packets were lost. If this was the case, the connection is already dead. Check the output of a ping command to see what it is grep'ing for - lost packets, not successful pings.

  7. #7
    Linux Newbie
    Join Date
    Sep 2005
    Location
    CZ
    Posts
    164

    Talking

    Right... My bad... I just saw something strange in that approach, that could result in false resetting... Hmm... And what about pinging? Maybe ping would be successful while web server service is down?

  8. #8
    Linux Newbie Ziplock's Avatar
    Join Date
    Jan 2009
    Location
    Adelaide
    Posts
    169
    Hi there,

    Please note that I said use an IP address from within your service provider, and to use traceroute to get this information. If you can't get to a host within your ISP, you probably can't get to the outside world, so a reset of the connection is in order.

    Also, if you can still ping the ISP host, and can't get to the web, then a reboot won't fix your problem anyway.

    Cheers,

    Ziplock

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...