Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 156255

Summary: DHCP option to prevent requesting the previously assigned IP address
Product: Gentoo Linux Reporter: sfp-a7x <gentoo-a7x>
Component: [OLD] baselayoutAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED WORKSFORME    
Severity: enhancement    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description sfp-a7x 2006-11-25 15:28:31 UTC
It would be nice to have an option in /etc/conf.d/net that prevents the chosen DHCP client from requesting the previously assigned IP address upon startup.

My /etc/conf.d/net is configured to use dhcpcd.  Unfortunately, dhcpcd does not have a command-line option for this; the file /var/lib/dhcpc/dhcpcd-eth0.cache must be deleted before starting dhcpcd.  I tried deleting the cache file using the following /etc/dhcpc/dhcpcd.exe script, but it does not appear to work (perhaps the DHCP server is remembering my MAC address?):

  #!/bin/bash
  
  if [[ "$2" == "down" ]] ; then
      CACHEFILE="$(echo "$1"|sed 's/\.info$/\.cache/')"
      if [[ -f "${CACHEFILE}" ]] ; then
          rm -rf "${CACHEFILE}"
      fi
  fi

I have not yet investigated the other DHCP clients to see if they can be configured to not request the previously assigned IP address, but for privacy reasons I figured it would be good to put in a request to support all DHCP clients in a generic way via /etc/conf.d/net.

Thanks!
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2006-11-25 17:35:24 UTC
1. The server may be configured to hand out a specific IP per MAC address
2. If you do not specifically DHCP_RELEASE your IP, and re-request it even without having the cache file, the server may give you the same one again.
2.1. The server may be configured to IGNORE DHCP_RELEASE messages.
3. The cache file only really has an effect where (your IP was released or expired from the server) AND (the IP in question is presently free) AND (the server honours specific requests).

It's possible best to delete the cache file using a preup block.

Test with the dhcpcd client manually with debugging on, and you can figure out which of the behaviors 1-3 are applicable to your DHCP server.
Comment 2 SpanKY gentoo-dev 2006-11-26 16:36:41 UTC
i dont see any change required in our net scripts ...
Comment 3 Roy Marples (RETIRED) gentoo-dev 2006-11-27 13:27:14 UTC
dhcpcd-3.0.0 doesn't use .cache files any more, which fixes this