diff --git a/src/lib/dhcp/dhcpcd b/src/lib/dhcp/dhcpcd index c729c08..da607c2 100644 --- a/src/lib/dhcp/dhcpcd +++ b/src/lib/dhcp/dhcpcd @@ -1,14 +1,40 @@ type dhcpcd &> /dev/null || return dhcpcd_start() { - if [[ $1 != "4" ]]; then - report_error "Using 'dhcpcd' for IPv6 is currently not possible in netctl" + if [[ $1 == "6" ]] && [[ $2 == "noauto" ]]; then + report_error "Using 'dhcpcd' for IPv6 noauto is currently not possible in netctl" return 1 fi + + if [[ $DHCPClient == "" ]]; then + DHCPClient="dhcpcd" + fi + + if [[ $DHCP6Client == "" ]]; then + DHCP6Client="dhclient" + fi + + if [[ $1 == "6" ]]; then + report_notice "Using 'dhcpcd' for IPv6 might not function correctly on networks without router advertisement." + #There's no need to start two instances of dhcpcd + if [[ $DHCPClient == "dhcpcd" ]] && [[ $DHCP6Client == "dhcpcd" ]]; then + report_notice "No need to run two instances of dhcpcd, gracefully aborting IPv6 instance" + return 0 + fi + fi rm -f "/run/dhcpcd-$Interface".{pid,cache} # If using own dns, tell dhcpcd to NOT replace resolv.conf [[ $DNS ]] && DhcpcdOptions+=" -C resolv.conf" - do_debug dhcpcd -4qL -t "${TimeoutDHCP:-30}" $DhcpcdOptions "$Interface" |& report_debug "$(cat)" + if [[ $DHCPClient == "dhcpcd" ]] && [[ $DHCP6Client != "dhcpcd" ]]; then + report_notice "No IPv6 enabled" + DhcpcdOptions="$DhcpcdOptions -4" + fi + if [[ $DHCPClient != "dhcpcd" ]] && [[ $DHCP6Client == "dhcpcd" ]]; then + DhcpcdOptions="$DhcpcdOptions -6" + fi + report_notice "DHCPClient=$DHCPClient" + report_notice "DHCP6Client=$DHCP6Client" + do_debug dhcpcd -qL -t "${TimeoutDHCP:-30}" $DhcpcdOptions "$Interface" |& report_debug "$(cat)" # The first array value of PIPESTATUS is the exit status of dhcpcd if (( PIPESTATUS != 0 )); then report_error "DHCP IP lease attempt failed on interface '$Interface'"