Skip to content

Instantly share code, notes, and snippets.

@cjac
Created April 21, 2020 05:29
Show Gist options
  • Save cjac/0e4702b633e318400be3ee273b0986a9 to your computer and use it in GitHub Desktop.
Save cjac/0e4702b633e318400be3ee273b0986a9 to your computer and use it in GitHub Desktop.
root@wanjet1:~# cat /etc/wide-dhcpv6/dhcp6c.conf
# Default dhpc6c configuration: it assumes the address is autoconfigured using
# router advertisements.
profile default
{
information-only;
request domain-name-servers;
request domain-name;
script "/etc/wide-dhcpv6/dhcp6c-script";
};
root@wanjet1:~# cat /etc/wide-dhcpv6/dhcp6c-script
#!/bin/sh
# dhcp6c-script for Debian/Ubuntu. Jérémie Corbier, April, 2006.
# resolvconf support by Mattias Guns, May 2006.
RESOLVCONF="/sbin/resolvconf"
[ -f /etc/default/wide-dhcpv6-client ] && . /etc/default/wide-dhcpv6-client
if [ -n "$new_domain_name" -o -n "$new_domain_name_servers" ]; then
old_resolv_conf=/etc/resolv.conf
new_resolv_conf=/etc/resolv.conf.dhcp6c-new
rm -f $new_resolv_conf
if [ -n "$new_domain_name" ]; then
echo search $new_domain_name >> $new_resolv_conf
fi
if [ -n "$new_domain_name_servers" ]; then
for nameserver in $new_domain_name_servers; do
# No need to add an already existing nameserver
res=$(grep "nameserver $nameserver" $old_resolv_conf)
if [ -z "$res" ]; then
echo nameserver $nameserver >> $new_resolv_conf
fi
done
fi
# Use resolvconf if available
if [ -h "$old_resolv_conf" -a -x "$RESOLVCONF" ]; then
for IFACE in $INTERFACES; do
cat $new_resolv_conf | $RESOLVCONF -a $IFACE
done
else
# To preserve IPv4 informations...
cat $old_resolv_conf >> $new_resolv_conf
chown --reference=$old_resolv_conf $new_resolv_conf
chmod --reference=$old_resolv_conf $new_resolv_conf
mv -f $new_resolv_conf $old_resolv_conf
fi
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment