[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Static IP /etc/network/interfaces, but got leased by dhcp



On Thu, Oct 10, 2013 at 09:45:22PM +0300, Ivan Kovnatsky wrote:
> Hi Guys,
> 
> I have static IP assignment in /etc/network/interfaces:
> --
> # Wireless
> auto wlan0
> iface wlan0 inet static
>         wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
>         address 192.168.1.49
>         netmask 255.255.255.0
>         gateway 192.168.1.1
> --
> 
> But somehow I could not ssh to my home laptop today, and found in logs:
> --
> Oct 10 06:40:54 lefrat dhclient: DHCPREQUEST on wlan0 to 192.168.1.1 port 67
> Oct 10 06:40:54 lefrat dhclient: DHCPACK from 192.168.1.1
> Oct 10 06:40:54 lefrat dhclient: bound to 192.168.1.218 -- renewal in 33574 seconds.
> --
> 
> Could you please clarify the reason of that, maybe I'm missing something.

Hm. This should not be happening.

Was it DHCP recently? (i.e. at any time since the last reboot) Because
this sequence of events would produce what you saw:

     Boot with the stanza saying "dhcp"
     Modify /etc/network/interfaces to static IP
     ifdown eth0 ; ifup eth0 # or /etc/init.d/networking restart

The snag is that the "ifdown" will NOT stop the DHCP client. Because
it sees no mention of DHCP in /etc/network/interfaces (at that
point). Then, later on, when the DHCP client renews the lease, I would
not be surprised if the IP address of the network interface is
updated.  Exactly when, depends on your lease time.

To avoid that, you should probably have done:

   cp /etc/network/interfaces /etc/network/interfaces.bak
   vi /etc/network/interfaces # or whatever your preferred editor is
   ifdown -i  /etc/network/interfaces.bak eth0
   ifup eth0

(it's good practice backing backups of such important files anyway).

Alternatively: when switching from dhcp to static: kill off any
remaining dhcp clients manually :-)

-- 
Karl E. Jorgensen


Reply to: