Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Retrieving old IP with DHCPCD
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
craigandrews
n00b
n00b


Joined: 08 Dec 2003
Posts: 6
Location: Sheffield, UK

PostPosted: Mon Dec 08, 2003 1:08 am    Post subject: Retrieving old IP with DHCPCD Reply with quote

Hi all,

I noticed soon after installing Gentoo that my ISP (Blueyonder) allocate dynamic IPs based purely on whether or not the client requests the previously assigned IP. If you fail to request the IP you had before, they will give you the next one in the pool. This means that I ended up getting a different IP every single time I booted the machine. Very annoying.

However, I discovered that it was due to the /etc/init.d/net.eth0 script terminating the dhcpcd daemon with 'dhcpcd -k' on shutdown. According to the man page, this:

"Sends SIGHUP signal to the dhcpcd process that is currently running. If dhcpcd receives SIGHUP it will send DHCP_RELEASE message to the server and destroy dhcpcd cache."

The solution is to change line 167 of /etc/init.d/net.eth* from:

Code:
while /sbin/dhcpcd -k ${IFACE} &>/dev/null && [ "${count}" -lt 9 ]


to:

Code:
while xargs kill < /var/run/dhcpcd-${IFACE}.pid &>/dev/null && [ "${count}" -lt 9 ]


This will send a SIGTERM rather than a SIGHUP and preserve the cached IP information over the boot process, ensuring that the same IP can be retrieved on next boot, and leaves IP assignment policy to the DHCP server where it belongs.
_________________
Craig Andrews <craig@simplyspiffing.com>

This .sig intentionally left blank
Back to top
View user's profile Send private message
razamatan
Apprentice
Apprentice


Joined: 28 Feb 2003
Posts: 160

PostPosted: Mon Dec 08, 2003 5:56 am    Post subject: Reply with quote

i'm using this version

Code:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.31 2003/09/08 00:11:54 azarah Exp $


of the net.eth* script...

it uses -z instead of -k as a switch... this sends a release, and doesn't destroy the cache...

Code:
       -z     Sends  SIGUSR1  signal  to  the dhcpcd process that is currently
              running. If dhcpcd receives SIGUSR1 it  will  send  DHCP_RELEASE
              message to the server without destroying the dhcpcd cache.


so the line looks like:
Code:
        while /sbin/dhcpcd -z ${IFACE} &>/dev/null && [ "${count}" -lt 9 ]

_________________
a razamatan doth speaketh,
"Never attribute to malice, that which can be adequately explained by stupidity"
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum