golfinguy
Posts: 19
Joined: Wed Aug 21, 2013 3:07 pm

Prevent DHCP release upon shutdown?

Thu Mar 20, 2014 3:17 am

Perhaps a strange need, but nonetheless I need to prevent the RPi from sending a 'release' to the server when it shuts down or reboots. I could not find anything obvious that I could turn on/off for this. I guess I could remove the ifdown from the shutdown altogether, but that seems harsh.

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Prevent DHCP release upon shutdown?

Thu Mar 20, 2014 7:09 am

I am afraid that you can not prevent ifdown from sending a DHCPRELEASE without patching/recompiling the ifupdown sources. Sending a DHCPRELEASE on shutdown is not a RFC requirement but it isn't prohibited either. Just came accross this :
http://pureperl.blogspot.be/2013/01/the ... e-and.html

I am sure you know how that you can always reserve a fix IP on the DHCP server based on the RPi's mac address.
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Prevent DHCP release upon shutdown?

Thu Mar 20, 2014 1:22 pm

Edit:
I think I found a work around. When you shut down your RPi, the /etc/init.d/networking script is invoqued, called by the rc.d hooks. In turn, the /etc/init.d/networking execute ifdown -a in the "stop)" and the "reload)" case switches. Just comment out these lines. Even better, if you want to deconfigure gracefully the interfaces before shut down, replace the ifdown command by the appropriate ip link set eth0 down command. I just checked with tcpdump, no DHCPRELEASE is sent in that case.
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

golfinguy
Posts: 19
Joined: Wed Aug 21, 2013 3:07 pm

Re: Prevent DHCP release upon shutdown?

Thu Apr 10, 2014 2:34 pm

ripat wrote:Edit:
I think I found a work around. When you shut down your RPi, the /etc/init.d/networking script is invoqued, called by the rc.d hooks. In turn, the /etc/init.d/networking execute ifdown -a in the "stop)" and the "reload)" case switches. Just comment out these lines. Even better, if you want to deconfigure gracefully the interfaces before shut down, replace the ifdown command by the appropriate ip link set eth0 down command. I just checked with tcpdump, no DHCPRELEASE is sent in that case.
Thats what I ended up doing - just commenting out the lines. Which is why I didn't come back to the thread - thanks though!

User avatar
RaTTuS
Posts: 10565
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Prevent DHCP release upon shutdown?

Thu Apr 10, 2014 2:45 pm

why do you want to do this ?

if it is to keep the same IP address then set it as fixed on your dhcp server
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

ne3e
Posts: 10
Joined: Fri Apr 20, 2012 2:09 pm

Re: Prevent DHCP release upon shutdown?

Thu Apr 10, 2014 2:53 pm

If you really want to keep the same IP address. Program your router/DHCP server with the IP address you want. This way every time your Pi goes to get a new address if will be provided with the same one. If your router cannot do this build a little DHCP server on another machine. Look on Google on how to do this.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Prevent DHCP release upon shutdown?

Mon Apr 14, 2014 5:47 pm

Instead of doing dhcp, I just assign a fixed address. Solves all those dhcp issues
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

tvjon
Posts: 798
Joined: Mon Jan 07, 2013 9:11 am

Re: Prevent DHCP release upon shutdown?

Tue Apr 15, 2014 10:53 am

My experience has been that in a relatively non-changing network, fixed is a good approach, but here devices are frequently added, & removed from the LAN, so fixed becomes awkward.

Usually I address devices as:

somedevice.local

which works just fine. The other day though I installed an "add-on" for openelec XBMC to monitor an ip camera. It didn't find said camera, so I did have to substitute its ip address. I think the source may be available for the add-on so I'll see if there's any way to change that behaviour.

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Prevent DHCP release upon shutdown?

Tue Apr 15, 2014 10:30 pm

tvjon wrote:My experience has been that in a relatively non-changing network, fixed is a good approach, but here devices are frequently added, & removed from the LAN, so fixed becomes awkward.

Usually I address devices as:

somedevice.local

which works just fine. The other day though I installed an "add-on" for openelec XBMC to monitor an ip camera. It didn't find said camera, so I did have to substitute its ip address. I think the source may be available for the add-on so I'll see if there's any way to change that behaviour.
You might try adding an entry for the camera in the /etc/hosts file if you want to reference it by name.

Return to “Raspberry Pi OS”