This disables IPv6 autoconfiguration by default. A router shouldn't
react on router advertisements or you get strange chaos in the ip
configuration.
It will be re-enabled if the protocol is DHCP.
Signed-off-by: Alina Friedrichsen <[email protected]>
Index: package/swconfig/files/switch.sh
===================================================================
--- package/swconfig/files/switch.sh (Revision 19074)
+++ package/swconfig/files/switch.sh (Arbeitskopie)
@@ -2,7 +2,9 @@
# Copyright (C) 2009 OpenWrt.org
setup_switch_dev() {
- ifconfig "$1" 0.0.0.0
+ sysctl -w "net.ipv6.conf.$1.autoconf=0" > /dev/null 2> /dev/null
+ ifconfig "$1" 0.0.0.0 down
+ ifconfig "$1" up
swconfig dev "$1" load network
}
Index: package/base-files/files/lib/network/config.sh
===================================================================
--- package/base-files/files/lib/network/config.sh (Revision 19074)
+++ package/base-files/files/lib/network/config.sh (Arbeitskopie)
@@ -165,6 +165,9 @@
local iface="$1"
local config="$2"
+ # Disable IPv6 autoconfiguration
+ sysctl -w "net.ipv6.conf.$iface.autoconf=0" > /dev/null 2> /dev/null
+
local ipaddr netmask ip6addr
config_get ipaddr "$config" ipaddr
config_get netmask "$config" netmask
@@ -233,48 +236,53 @@
}
setup_interface() {
- local iface="$1"
+ local iface0="$1"
local config="$2"
local proto="$3"
local vifmac="$4"
+ local ip6addr0=
[ -n "$config" ] || {
- config=$(find_config "$iface")
+ config=$(find_config "$iface0")
[ "$?" = 0 ] || return 1
}
- prepare_interface "$iface" "$config" "$vifmac" || return 0
+ prepare_interface "$iface0" "$config" "$vifmac" || return 0
- [ "$iface" = "br-$config" ] && {
+ [ "$iface0" = "br-$config" ] && {
# need to bring up the bridge and wait a second for
# it to switch to the 'forwarding' state, otherwise
# it will lose its routes...
- ifconfig "$iface" up
+ ifconfig "$iface0" up
sleep 1
}
# Interface settings
- grep "$iface:" /proc/net/dev > /dev/null && {
+ grep "$iface0:" /proc/net/dev > /dev/null && {
local mtu macaddr
config_get mtu "$config" mtu
config_get macaddr "$config" macaddr
- [ -n "$macaddr" ] && $DEBUG ifconfig "$iface" down
- $DEBUG ifconfig "$iface" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} up
+ [ -n "$macaddr" ] && $DEBUG ifconfig "$iface0" down
+ $DEBUG ifconfig "$iface0" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} up
}
- set_interface_ifname "$config" "$iface"
+ set_interface_ifname "$config" "$iface0"
- pidfile="/var/run/$iface.pid"
+ pidfile="/var/run/$iface0.pid"
[ -n "$proto" ] || config_get proto "$config" proto
case "$proto" in
static)
- setup_interface_static "$iface" "$config"
+ config_get ip6addr0 "$config" ip6addr
+ setup_interface_static "$iface0" "$config"
;;
dhcp)
+ # Enable IPv6 autoconfiguration
+ sysctl -w "net.ipv6.conf.$iface0.autoconf=1" > /dev/null 2> /dev/null
+
# prevent udhcpc from starting more than once
- lock "/var/lock/dhcp-$iface"
+ lock "/var/lock/dhcp-$iface0"
local pid="$(cat "$pidfile" 2>/dev/null)"
if [ -d "/proc/$pid" ] && grep udhcpc "/proc/${pid}/cmdline" >/dev/null 2>/dev/null; then
- lock -u "/var/lock/dhcp-$iface"
+ lock -u "/var/lock/dhcp-$iface0"
else
local ipaddr netmask hostname proto1 clientid
config_get ipaddr "$config" ipaddr
@@ -284,21 +292,21 @@
config_get clientid "$config" clientid
[ -z "$ipaddr" ] || \
- $DEBUG ifconfig "$iface" "$ipaddr" ${netmask:+netmask "$netmask"}
+ $DEBUG ifconfig "$iface0" "$ipaddr" ${netmask:+netmask "$netmask"}
# don't stay running in background if dhcp is not the main proto on the interface (e.g. when using pptp)
local dhcpopts
[ ."$proto1" != ."$proto" ] && dhcpopts="-n -q"
- $DEBUG eval udhcpc -t 0 -i "$iface" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} ${clientid:+-c $clientid} -b -p "$pidfile" ${dhcpopts:- -O rootpath -R &}
- lock -u "/var/lock/dhcp-$iface"
+ $DEBUG eval udhcpc -t 0 -i "$iface0" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} ${clientid:+-c $clientid} -b -p "$pidfile" ${dhcpopts:- -O rootpath -R &}
+ lock -u "/var/lock/dhcp-$iface0"
fi
;;
none)
- setup_interface_none "$iface" "$config"
+ setup_interface_none "$iface0" "$config"
;;
*)
if ( eval "type setup_interface_$proto" ) >/dev/null 2>/dev/null; then
- eval "setup_interface_$proto '$iface' '$config' '$proto'"
+ eval "setup_interface_$proto '$iface0' '$config' '$proto'"
else
echo "Interface type $proto not supported."
return 1
@@ -306,7 +314,7 @@
;;
esac
[ "$proto" = none ] || {
- for ifn in `ifconfig | grep "^$iface:" | awk '{print $1}'`; do
+ for ifn in `ifconfig | grep "^$iface0:" | awk '{print $1}'`; do
ifconfig "$ifn" down
done
}
@@ -314,9 +322,15 @@
local aliases
config_set "$config" aliases ""
config_set "$config" alias_count 0
- config_foreach setup_interface_alias alias "$config" "$iface"
+ config_foreach setup_interface_alias alias "$config" "$iface0"
config_get aliases "$config" aliases
[ -z "$aliases" ] || uci_set_state network "$config" aliases "$aliases"
+
+ # put the ip6addr back to the beginning to become the main ip again
+ [ -z "$ip6addr0" ] || {
+ $DEBUG ifconfig "$iface0" del "$ip6addr0"
+ $DEBUG ifconfig "$iface0" add "$ip6addr0"
+ }
}
unbridge() {
Index: package/base-files/files/etc/init.d/boot
===================================================================
--- package/base-files/files/etc/init.d/boot (Revision 19074)
+++ package/base-files/files/etc/init.d/boot (Arbeitskopie)
@@ -72,6 +72,9 @@
/usr/bin/env -i ACTION=add INTERFACE="$iface" /sbin/hotplug-call net
done
+ # Disable IPv6 autoconfiguration by default
+ sysctl -w "net.ipv6.conf.all.autoconf=0" > /dev/null 2> /dev/null
+
# create /dev/root if it doesn't exist
[ -e /dev/root ] || {
rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
Index: package/switch/files/switch.sh
===================================================================
--- package/switch/files/switch.sh (Revision 19074)
+++ package/switch/files/switch.sh (Arbeitskopie)
@@ -15,6 +15,10 @@
echo "$evlan" > "$proc/enable_vlan"
echo "$enable" > "$proc/enable"
}
+
+ sysctl -w "net.ipv6.conf.$dev.autoconf=0" > /dev/null 2> /dev/null
+ ifconfig "$dev" 0.0.0.0 down
+ ifconfig "$dev" up
}
setup_switch_vlan() {
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel