{
    "mode": "man",
    "parameter": "dhclient-script",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/dhclient-script/8/json",
    "generated": "2026-10-08T07:41:11Z",
    "sections": {
        "NAME": {
            "content": "dhclient-script - DHCP client network configuration script\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  DHCP  client  network  configuration script is invoked from time to time by dhclient(8).\nThis script is used by the dhcp client to set each interface's initial configuration prior to\nrequesting an address, to test the address once it has been offered, and to  set  the  inter‐\nface's  final  configuration  once  a  lease has been acquired.  If no lease is acquired, the\nscript is used to test predefined leases, if any, and also called once if no valid lease  can\nbe identified.\n\nThis  script  is  not  meant  to  be customized by the end user.  If local customizations are\nneeded, they should be possible using the enter and exit hooks provided (see  HOOKS  for  de‐\ntails).    These hooks will allow the user to override the default behaviour of the client in\ncreating a /etc/resolv.conf file.\n\nNo standard client script exists for some operating systems, even though  the  actual  client\nmay  work,  so  a  pioneering user may well need to create a new script or modify an existing\none.  In general, customizations specific to a particular computer  should  be  done  in  the\n/etc/dhcp/dhclient.conf  file.   If you find that you can't make such a customization without\ncustomizing /etc/dhcp/dhclient.conf or using the enter and exit hooks, please  submit  a  bug\nreport.\n",
            "subsections": []
        },
        "HOOKS": {
            "content": "When it starts, the client script first defines a shell function, makeresolvconf , which is\nlater used to create the /etc/resolv.conf file.   To override the default behaviour, redefine\nthis function in the enter hook script.\n\nAfter defining the makeresolvconf function, the client script checks for the presence of an\nexecutable  /etc/dhcp/dhclient-enter-hooks  script, and if present, it invokes the script in‐\nline, using the Bourne shell ´.´  command.    It  also  invokes  all  executable  scripts  in\n/etc/dhcp/dhclient-enter-hooks.d/* in the same way.   The entire environment documented under\nOPERATION  is  available to this script, which may modify the environment if needed to change\nthe behaviour of the script.   If an error occurs during the execution of the script, it  can\nset  the  exitstatus  variable  to a nonzero value, and /sbin/dhclient-script will exit with\nthat error code immediately after the client script exits.\n\nAfter all processing has completed, /sbin/dhclient-script checks for the presence of an  exe‐\ncutable  /etc/dhcp/dhclient-exit-hooks script, which if present is invoked using the '.' com‐\nmand.  All executable scripts in /etc/dhcp/dhclient-exit-hooks.d/* are  also  invoked.    The\nexit status of dhclient-script will be passed to dhclient-exit-hooks in the exitstatus shell\nvariable,  and  will  always be zero if the script succeeded at the task for which it was in‐\nvoked.   The rest of the environment as described previously for dhclient-enter-hooks is also\npresent.   The /etc/dhcp/dhclient-exit-hooks  and  /etc/dhcp/dhclient-exit-hooks.d/*  scripts\ncan modify the value of exitstatus to change the exit status of dhclient-script.\n",
            "subsections": []
        },
        "OPERATION": {
            "content": "When  dhclient needs to invoke the client configuration script, it defines a set of variables\nin the environment, and then invokes /sbin/dhclient-script.  In all cases, $reason is set  to\nthe name of the reason why the script has been invoked.   The following reasons are currently\ndefined:  MEDIUM, PREINIT, BOUND, RENEW, REBIND, REBOOT, EXPIRE, FAIL, STOP, RELEASE, NBI and\nTIMEOUT.\n",
            "subsections": []
        },
        "MEDIUM": {
            "content": "The DHCP client is requesting that an interface's media type be set.  The interface  name  is\npassed in $interface, and the media type is passed in $medium.\n",
            "subsections": []
        },
        "PREINIT": {
            "content": "The  DHCP  client  is requesting that an interface be configured as required in order to send\npackets prior to receiving an actual address.   For clients which use the BSD socket library,\nthis means configuring the interface with an IP address of 0.0.0.0 and a broadcast address of\n255.255.255.255.   For other clients, it may be possible to simply configure the interface up\nwithout actually giving it an IP address at all.   The interface name is  passed  in  $inter‐\nface, and the media type in $medium.\n\nIf  an  IP  alias  has  been  declared  in  dhclient.conf,  its  address  will  be  passed in\n$aliasipaddress, and that ip alias should be deleted from the  interface,  along  with  any\nroutes to it.\n",
            "subsections": []
        },
        "BOUND": {
            "content": "The  DHCP client has done an initial binding to a new address.   The new ip address is passed\nin $newipaddress, and the interface name is passed  in  $interface.    The  media  type  is\npassed  in  $medium.    Any options acquired from the server are passed using the option name\ndescribed in dhcp-options, except that dashes (´-´) are replaced by underscores (´´) in  or‐\nder  to  make valid shell variables, and the variable names start with new.  So for example,\nthe new subnet mask would be passed in $newsubnetmask.  Options from a non-default universe\nwill have the universe name prepended to the option name, for  example  $newdhcp6serverid.\nThe  options that the client explicitly requested via a PRL or ORO option are passed with the\nsame option name as above but prepended with requested and with a value of  1,  for  example\nrequestedsubnetmask=1.  No such variable is defined for options not requested by the client\nor  options that don't require a request option, such as the ip address (*ipaddress) or ex‐\npiration time (*expiry).\n\nBefore actually configuring the address, dhclient-script should somehow ARP for it  and  exit\nwith  a nonzero status if it receives a reply.   In this case, the client will send a DHCPDE‐\nCLINE message to the server and acquire a different address.   This may also be done  in  the\nRENEW, REBIND, or REBOOT states, but is not required, and indeed may not be desirable.\n\nWhen  a  binding has been completed, a lot of network parameters are likely to need to be set\nup.   A new /etc/resolv.conf needs to be created, using the values  of  $newdomainname  and\n$newdomainnameservers  (which may list more than one server, separated by spaces).   A de‐\nfault route should be set using $newrouters, and static routes may need to be set  up  using\n$newstaticroutes.\n\nIf  an  IP  alias  has  been declared, it must be set up here.   The alias IP address will be\nwritten as $aliasipaddress, and other DHCP options that are set for the alias (e.g., subnet\nmask) will be passed in variables named as described previously except starting with  $alias\ninstead of $new.   Care should be taken that the alias IP address not be used if it is iden‐\ntical  to the bound IP address ($newipaddress), since the other alias parameters may be in‐\ncorrect in this case.\n",
            "subsections": []
        },
        "RENEW": {
            "content": "When a binding has been renewed, the script is called as in BOUND, except that in addition to\nall the variables starting with $new, and $requested there  is  another  set  of  variables\nstarting  with $old.  Persistent settings that may have changed need to be deleted - for ex‐\nample, if a local route to the bound address is being configured, the old local route  should\nbe  deleted.   If the default route has changed, the old default route should be deleted.  If\nthe static routes have changed, the old ones should be deleted.  Otherwise, processing can be\ndone as with BOUND.\n",
            "subsections": []
        },
        "REBIND": {
            "content": "The DHCP client has rebound to a new DHCP server.  This can be handled as with RENEW,  except\nthat if the IP address has changed, the ARP table should be cleared.\n",
            "subsections": []
        },
        "REBOOT": {
            "content": "The  DHCP  client  has  successfully reacquired its old address after a reboot.   This can be\nprocessed as with BOUND.\n",
            "subsections": []
        },
        "EXPIRE": {
            "content": "The DHCP client has failed to renew its lease or acquire a new one, and  the  lease  has  ex‐\npired.    The  IP address must be relinquished, and all related parameters should be deleted,\nas in RENEW and REBIND.\n",
            "subsections": []
        },
        "FAIL": {
            "content": "The DHCP client has been unable to contact any DHCP servers, and any leases  that  have  been\ntested have not proved to be valid.   The parameters from the last lease tested should be de‐\nconfigured.   This can be handled in the same way as EXPIRE.\n",
            "subsections": []
        },
        "STOP": {
            "content": "The  dhclient has been informed to shut down gracefully, the dhclient-script should unconfig‐\nure or shutdown the interface as appropriate.\n",
            "subsections": []
        },
        "RELEASE": {
            "content": "The dhclient has been executed using the -r flag, indicating that the administrator wishes it\nto release its lease(s).  dhclient-script should unconfigure or shutdown the interface.\n",
            "subsections": []
        },
        "NBI": {
            "content": "No-Broadcast-Interfaces...dhclient was unable to find any interfaces upon which  it  believed\nit  should commence DHCP.  What dhclient-script should do in this situation is entirely up to\nthe implementor.\n",
            "subsections": []
        },
        "TIMEOUT": {
            "content": "The DHCP client has been unable to contact any DHCP servers.  However, an old lease has  been\nidentified,  and its parameters have been passed in as with BOUND.   The client configuration\nscript should test these parameters and, if it has reason to believe they are  valid,  should\nexit with a value of zero.   If not, it should exit with a nonzero value.\n",
            "subsections": []
        },
        "V6ONLY": {
            "content": "The  DHCPv4 client has received a requested valid v6-only-preferred option. The system should\ndisable IPv4 on the interface. On its side the dhclient waits for  V6ONLYWAIT  seconds  (the\ntimer  is  carried  by  the option with a minimum of MINV6ONLYWAIT) before returning in the\nINIT state.\n\nThe usual way to test a lease is to set up the network as with  REBIND  (since  this  may  be\ncalled to test more than one lease) and then ping the first router defined in $routers.  If a\nresponse  is received, the lease must be valid for the network to which the interface is cur‐\nrently connected.   It would be more complete to try to ping all of  the  routers  listed  in\n$newrouters,  as  well  as those listed in $newstaticroutes, but current scripts do not do\nthis.\n",
            "subsections": []
        },
        "FILES": {
            "content": "Each operating system should generally have its own script file, although  the  script  files\nfor  similar  operating systems may be similar or even identical.   The script files included\nin Internet Systems Consortium DHCP  distribution  appear  in  the  distribution  tree  under\nclient/scripts,  and  bear  the  names of the operating systems on which they are intended to\nwork.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "If more than one interface is being used, there's no obvious way  to  avoid  clashes  between\nserver-supplied  configuration  parameters  - for example, the stock dhclient-script rewrites\n/etc/resolv.conf.   If more than one interface is being configured, /etc/resolv.conf will  be\nrepeatedly  initialized  to the values provided by one server, and then the other.   Assuming\nthe information provided by both servers is valid, this shouldn't cause  any  real  problems,\nbut it could be confusing.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "dhclient(8), dhcpd(8), dhcrelay(8), dhclient.conf(5) and dhclient.leases(5).\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "dhclient-script(8) To learn more about Internet Systems Consortium, see https://www.isc.org.\n\ndhclient-script(8)",
            "subsections": []
        }
    },
    "summary": "dhclient-script - DHCP client network configuration script",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "dhclient",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/dhclient/8/json"
        },
        {
            "name": "dhcpd",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/dhcpd/8/json"
        },
        {
            "name": "dhcrelay",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/dhcrelay/8/json"
        },
        {
            "name": "dhclient.conf",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/dhclient.conf/5/json"
        },
        {
            "name": "dhclient.leases",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/dhclient.leases/5/json"
        }
    ]
}