From e551d6e412a5bd9738e144d483f1ab89fe1251a7 Mon Sep 17 00:00:00 2001 From: garywill <32130780+garywill@users.noreply.github.com> Date: Fri, 31 Aug 2018 18:41:06 +0800 Subject: [PATCH] disable IPv6 if not enabled --- lnxrouter | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lnxrouter b/lnxrouter index 22a4f77..9c40355 100755 --- a/lnxrouter +++ b/lnxrouter @@ -811,7 +811,7 @@ _cleanup() { ip addr flush ${SUBNET_IFACE} - if [[ $IPV6 -eq 1 ]]; then + if [[ -d $CONFDIR/sys_6_conf_iface ]]; then cp -f $CONFDIR/sys_6_conf_iface/* /proc/sys/net/ipv6/conf/$SUBNET_IFACE/ fi rm -rf $CONFDIR @@ -1501,8 +1501,9 @@ if [[ $WIFI_IFACE ]]; then fi ip addr add ${GATEWAY}/24 broadcast ${GATEWAY%.*}.255 dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} IP" + +mkdir $CONFDIR/sys_6_conf_iface if [[ $IPV6 -eq 1 ]]; then - mkdir $CONFDIR/sys_6_conf_iface cp /proc/sys/net/ipv6/conf/$SUBNET_IFACE/accept_ra \ /proc/sys/net/ipv6/conf/$SUBNET_IFACE/use_tempaddr \ /proc/sys/net/ipv6/conf/$SUBNET_IFACE/addr_gen_mode \ @@ -1513,6 +1514,9 @@ if [[ $IPV6 -eq 1 ]]; then echo 0 > /proc/sys/net/ipv6/conf/$SUBNET_IFACE/addr_gen_mode ip -6 addr add ${GATEWAY6}/64 dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} IPv6" +else + cp /proc/sys/net/ipv6/conf/$SUBNET_IFACE/disable_ipv6 $CONFDIR/sys_6_conf_iface/ + echo 1 > /proc/sys/net/ipv6/conf/$SUBNET_IFACE/disable_ipv6 fi # enable Internet sharing