Web lists-archives.com

Re: DHCP to static without reboot?





On Sat, 25 Aug 2018, Mark Pavlichuk wrote:

> I can't seem to change the configuration of a nic from DHCP to static in
> Stretch (without rebooting) - I do this a lot so I don't want to have to
> reboot every time.  I'm using the old "killall dhclient;ifdown eth0;ifup eth0"
> method which also still seems to be in the documentation... at least on the
> debian.org site.  I've also tried doing various combinations of "service
> stop/start/restart networking" along with ifup/ifdown commands to no avail. 
> Is there some special new magic?
> 
> -- 
> Mark Pavlichuk
> 
> 

I don't know what "killall dhclient;ifdown eth0;ifup eth0" method is but I 
never found that necessary.  You should be able to bring the iface down, 
then edit interfaces file, then bring it up with the new config.  I don't 
think restarting networking service is what you want, it does not do the 
same thing as the old /etc/init.d/networking restart command did.

Alternately I have used separate iface names for each config and used 
something like ifup wlan0=cfg_static ifup wlan0=cfg_dhcp 
depending on which I wanted.


iface cfg_static inet dhcp
     address 192.168.1.109
iface cfg_dhcp inet dhcp

good luck