Find the answer to your Linux question:
Results 1 to 7 of 7
Whenever I disconnect the LAN cable from my Linux box or reset the router the IP doesn't seem to get renewed and so I'm unable to SSH into it or ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! juliushibert's Avatar
    Join Date
    Jul 2010
    Posts
    6

    Question Not renewing IP when LAN cable is disconnected


    Whenever I disconnect the LAN cable from my Linux box or reset the router the IP doesn't seem to get renewed and so I'm unable to SSH into it or connected to the webservices it is running.

    When it boots up it gets an IP fine from DHCP on the router but once the system is up and something changes like the router reboots or cable is disconnected, then this is when the problem occurs.

    sometimes if you go back to the actual Linux box in my loft and open a terminal and run

    cd /etc/init.d/
    ./networking restart

    this will cause it to get a new IP from the DHCP server but this isn't very convinient and a bit haphazard.

    Any ideas if theres a way to fix this?

  2. #2
    Linux Newbie
    Join Date
    Jul 2005
    Location
    Australia (Down Under)
    Posts
    141
    Gday, Ive found that the following has fixed this issue for me in the past.

    edit your /etc/network/interfaces and add "auto eth0" and "allow-hotplug" before your network adapter.

    So your interfaces file should look similar to this:

    Code:
    auto lo
    iface lo inet loopback
    
    allow-hotplug eth0 
    auto eth0
    iface eth0 inet dhcp
    Hope that helps

    This assumes that your network interface is eth0, otherwise change the eth0 to eth1 or what ever it is!
    Linux is the OS of tomorrow, Here today!!

  3. #3
    Just Joined! juliushibert's Avatar
    Join Date
    Jul 2010
    Posts
    6
    Thanks for your help crazy01. I think that seems to be working but something I guess I'll have to try out over the next few days. But for the moment it seems to work correctly.

    Just one thing. When I'm actually at the Linux box and type

    ifconfig with cable connected

    the IP is fine and then when I disconnect the cable and type

    ifconfig

    it still seems to retain that same IP and doesn't say default to showing no IP or 0.0.0.0 or a self assigned one as it would do on my OS X/Mac machine. Don't know if this means it's still working correctly?

    Thanks again crazy01.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Jul 2005
    Location
    Australia (Down Under)
    Posts
    141
    umm... yeah that seems normal.. well for me at least. 99% of my linux boxes have static IP addresses so this is not really an issue for me. but i know that occasionally i need to restart the networking service to drop the DHCP assigned IP Address.

    To restart networking Service
    Code:
    /etc/init.d/networking restart
    Glad to help!!
    Linux is the OS of tomorrow, Here today!!

  6. #5
    Just Joined! juliushibert's Avatar
    Join Date
    Jul 2010
    Posts
    6
    For some reason my current router wont hand out static IPs based on MAC code. Pretty annoying really so I've ordered a new N router that can take DD-WRT and hopefully avoid any more hassel.

    Thanks again for your help crazy01.

  7. #6
    Linux User
    Join Date
    Sep 2008
    Location
    UK
    Posts
    358
    Quote Originally Posted by juliushibert View Post
    For some reason my current router wont hand out static IPs based on MAC code. Pretty annoying really so I've ordered a new N router that can take DD-WRT and hopefully avoid any more hassel.
    If the router's dhcp server doesn't renew leases with the and give same ipaddress on renewal, having a router that is dd=wrt capable isn't the solution.
    All dd-wrt does is allow you to bridge wireless networks.

    By design the dhcp server should renew the lease with the same ip address to the same client, as long as the address hasn't been given to someone else.
    In a small network, if you disconnect the cable nad the replug it, renewing the lease should give the same address.
    The equivalent linux command to the windows ipconfig /renew command is:

    either:
    /etc/init.d/network restart

    or
    dhclient

    You eiter need to configure the hotplug option that is give above or explicitly renew the lease when the network is unavailable.
    Last edited by whych; 07-28-2010 at 12:50 AM.

  8. #7
    Just Joined! juliushibert's Avatar
    Join Date
    Jul 2010
    Posts
    6
    The code that crazy01 gave me worked a treat;

    Code:
    auto lo
    iface lo inet loopback
    
    allow-hotplug eth0 
    auto eth0
    iface eth0 inet dhcp

    I also changed to a DD-WRT router which seems to help as well as unlike my old Linksys WAG router it allows you to specify a static DHCP table and hands out the same IP every time based on the clients MAC address.

    If the router's dhcp server doesn't renew leases with the and give same ipaddress on renewal, having a router that is dd=wrt capable isn't the solution.
    All dd-wrt does is allow you to bridge wireless networks.
    DD-WRT can be used to bridge wireless networks but can also be used for a myraid of other things including acting as a DHCP server.

Posting Permissions

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