Skip to content

Instantly share code, notes, and snippets.

@fdv
Last active April 16, 2018 10:00
Show Gist options
  • Save fdv/e2af9150d3f98d2a5a0ff4827888b882 to your computer and use it in GitHub Desktop.
Save fdv/e2af9150d3f98d2a5a0ff4827888b882 to your computer and use it in GitHub Desktop.
Dhclient6 for FreeBSD configuration

Install the package

pkg install isc-dhcp43-client

/etc/rc.conf

ipv6_enable_all_interfaces="YES"
ifconfig_em0_ipv6="inet6 -ifdisabled accept_rtadv up"
rtsold_enable="YES"
dhclient6_iface="em0"
dhclient6_enable="YES"

/usr/local/etc/dhclient6.conf

interface "em0" {
  send dhcp6.client-id DH:CP:UD:ID;
}

/usr/local/etc/rc.d/dhclient6

#!/bin/sh
#
# PROVIDE: dhclient6
# REQUIRE: DAEMON
# KEYWORD: dhcp
#
# Add the following lines to /etc/rc.conf to enable dhclient6:
#
# dhclient6_enable="YES"
#

. /etc/rc.subr

name="dhclient6"
desc="ISC DHCPv6 client"
rcvar="dhclient6_enable"

start_cmd="dhclient6_start"
stop_cmd="dhclient6_stop"

dhclient6_start()
{
          /usr/local/sbin/dhclient -cf "${dhclient6_conf}" -P -v "${dhclient6_iface}"

}

dhclient6_stop()
{
  if [ -r "${dhclient6_pid}" ]
  then
    kill -- -$(cat "${dhclient6_pid}")
    rm -f "${dhclient6_pid}"
  fi
}

load_rc_config ${name}

: ${dhclient6_enable="NO"}
: ${dhclient6_pid="/var/run/dhclient6.pid"}
: ${dhclient6_conf="/usr/local/etc/dhclient6.conf"}
: ${dhclient6_iface=""}

run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment