if [ "${addr}" != "-" ]; then
ip netns exec ${ns} ip addr add dev lo ${addr} fi if [ "${addr6}" != "-" ]; then
ip netns exec ${ns} ip -6 addr add dev lo ${addr6} fi
ip netns exec ${ns} ip ro add unreachable default metric 8192
ip netns exec ${ns} ip -6 ro add unreachable default metric 8192
ip netns exec ${ns} sysctl -qw net.ipv4.ip_forward=1
ip netns exec ${ns} sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1
ip netns exec ${ns} sysctl -qw net.ipv6.conf.all.forwarding=1
ip netns exec ${ns} sysctl -qw net.ipv6.conf.default.forwarding=1
ip netns exec ${ns} sysctl -qw net.ipv6.conf.default.accept_dad=0
}
# create veth pair to connect namespaces and apply addresses.
connect_ns()
{
local ns1=$1
local ns1_dev=$2
local ns1_addr=$3
local ns1_addr6=$4
local ns2=$5
local ns2_dev=$6
local ns2_addr=$7
local ns2_addr6=$8
ip netns exec ${ns1} ip li add ${ns1_dev} type veth peer name tmp
ip netns exec ${ns1} ip li set ${ns1_dev} up
ip netns exec ${ns1} ip li set tmp netns ${ns2} name ${ns2_dev}
ip netns exec ${ns2} ip li set ${ns2_dev} up
if [ "${ns1_addr}" != "-" ]; then
ip netns exec ${ns1} ip addr add dev ${ns1_dev} ${ns1_addr} fi
if [ "${ns2_addr}" != "-" ]; then
ip netns exec ${ns2} ip addr add dev ${ns2_dev} ${ns2_addr} fi
if [ "${ns1_addr6}" != "-" ]; then
ip netns exec ${ns1} ip addr add dev ${ns1_dev} ${ns1_addr6} fi
if [ "${ns2_addr6}" != "-" ]; then
ip netns exec ${ns2} ip addr add dev ${ns2_dev} ${ns2_addr6} fi
}
################################################################################ # traceroute6 test # # Verify that in this scenario # # ------------------------ N2 # | | # ------ ------ N3 ---- # | R1 | | R2 |------|H2| # ------ ------ ---- # | | # ------------------------ N1 # | # ---- # |H1| # ---- # # where H1's default route goes through R1 and R1's default route goes # through R2 over N2, traceroute6 from H1 to H2 reports R2's address # on N2 and not N1. # # Addresses are assigned as follows: # # N1: 2000:101::/64 # N2: 2000:102::/64 # N3: 2000:103::/64 # # R1's host part of address: 1 # R2's host part of address: 2 # H1's host part of address: 3 # H2's host part of address: 4 # # For example: # the IPv6 address of R1's interface on N2 is 2000:102::1/64
# Setup N3
connect_ns $r2 eth3 - 2000:103::2/64 $h2 eth3 - 2000:103::4/64
ip netns exec $h2 ip route add default via 2000:103::2
# Setup N2
connect_ns $r1 eth2 - 2000:102::1/64 $r2 eth2 - 2000:102::2/64
ip netns exec $r1 ip route add default via 2000:102::2
# Setup N1. host-1 and router-2 connect to a bridge in router-1.
ip netns exec $r1 ip link add name ${brdev} type bridge
ip netns exec $r1 ip link set ${brdev} up
ip netns exec $r1 ip addr add 2000:101::1/64 dev ${brdev}
connect_ns $h1 eth0 - 2000:101::3/64 $r1 eth0 - -
ip netns exec $r1 ip link set dev eth0 master ${brdev}
ip netns exec $h1 ip route add default via 2000:101::1
connect_ns $r2 eth1 - 2000:101::2/64 $r1 eth1 - -
ip netns exec $r1 ip link set dev eth1 master ${brdev}
# Prime the network
ip netns exec $h1 ping6 -c5 2000:103::4 >/dev/null 2>&1
set +e
}
run_traceroute6()
{
setup_traceroute6
RET=0
# traceroute6 host-2 from host-1 (expects 2000:102::2)
run_cmd $h1 "traceroute6 2000:103::4 | grep -q 2000:102::2"
check_err $? "traceroute6 did not return 2000:102::2"
log_test "IPv6 traceroute"
cleanup_traceroute6
}
################################################################################ # traceroute test # # Verify that traceroute from H1 to H2 shows 1.0.1.1 in this scenario # # 1.0.3.1/24 # ---- 1.0.1.3/24 1.0.1.1/24 ---- 1.0.2.1/24 1.0.2.4/24 ---- # |H1|--------------------------|R1|--------------------------|H2| # ---- N1 ---- N2 ---- # # where net.ipv4.icmp_errors_use_inbound_ifaddr is set on R1 and # 1.0.3.1/24 and 1.0.1.1/24 are respectively R1's primary and secondary # address on N1. #
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.