I have a bunch of RPis running in read-only filesystems that are not able to modify the /etc/network/interfaces file.As of right now, they load their configurations off of a USB stick and use ifconfig eth0 <ipaddress> to change their IP addresses.  This is working most of the time, but every once and a while, the IP change doesn't stick.  My startup script runs, the IP changes to the configured address, then a minute or so later, it changes to an incorrect address.My interfaces file is setup for DHCP: iface eth0 inet dhcp because I still want to be able to find the Pi on the network if something goes wrong.So, I am thinking that DHCP is taking its sweet time and overriding my IP change a minute or so after boot.How can I disable DHCP without altering any filesystem files?
Disable DHCP without altering 'interfaces'
dhcp;networking
In your case, you may be able to get away with running killall dhclient to kill all running DHCP client daemons using dhclient -r to gracefully stop the DHCP client daemons*. Wouldn't normally recommend this, but if modifying the base system is out of the question and you need to rely on startup scripts, killing the dhclient process(es) would be my recommendation.However, if the USB stick is a non-persistent live USB, it should still allow for editing files on the live system, but the changes won't persist across reboots. In that case, my recommendation would be to ifdown the interface, echo out the /etc/network/interfaces file with the appropriate configs, and then ifup the interface in your script. The benefit of this would be that if the interface restarts or resets at any point, your custom config is more likely to stick, while it might not otherwise (though I'll admit I haven't tested this kind of situation, I'm just a bit cautious).*edit thanks to goldilocks' suggestion in comments