Se uma interface estiver dentro de um namespace, qualquer comando para operar nessa interface deve ser executado nesse namespace.
Eu criei 6 namespaces e anexei links veth entre eles. Estou tentando configurar atraso e largura de banda para os links, mas o seguinte erro é mostrado:
Cannot find device "eth0"
Cannot find device "eth0"
Cannot find device "eth0"
Cannot find device "eth0"
Aqui está o meu código:
# Add namespaces
ip netns add ns1
ip netns add ns2
ip netns add ns3
ip netns add ns4
ip netns add ns5
ip netns add ns6
# Add veths
ip link add eth0 type veth peer name eth1
ip link add eth2 type veth peer name eth3
ip link add eth4 type veth peer name eth5
ip link add eth6 type veth peer name eth7
ip link add eth8 type veth peer name eth9
#link veths
ip link set netns ns1 eth0
ip link set netns ns2 eth3
ip link set netns ns3 eth6
ip link set netns ns4 eth9
ip link set netns ns5 eth1
ip link set netns ns5 eth2
ip link set netns ns5 eth4
ip link set netns ns6 eth5
ip link set netns ns6 eth7
ip link set netns ns6 eth8
#assign mac's
ip netns exec ns1 ifconfig eth0 hw ether 02:03:01:04:06:07
ip netns exec ns2 ifconfig eth3 hw ether 02:03:01:04:05:06
ip netns exec ns3 ifconfig eth6 hw ether 02:03:06:05:07:04
ip netns exec ns4 ifconfig eth9 hw ether 02:03:06:05:07:09
#assign ip's
ip netns exec ns1 ifconfig eth0 10.1.1.1/24 up
ip netns exec ns2 ifconfig eth3 10.1.1.2/24 up
ip netns exec ns3 ifconfig eth6 10.1.1.3/24 up
ip netns exec ns4 ifconfig eth9 10.1.1.4/24 up
#setup bridge 1
brctl addbr br1
ip link del dev br1
ip netns exec ns5 brctl addbr br1
for i in 1 2 4; do
ip netns exec ns5 brctl addif br1 eth$i
ip netns exec ns5 ip link set up dev eth$i
done
ip netns exec ns5 ip link set up dev br1
#setup bridge 2
brctl addbr br2
ip link del dev br2
ip netns exec ns6 brctl addbr br2
for i in 5 7 8; do
ip netns exec ns6 brctl addif br2 eth$i
ip netns exec ns6 ip link set up dev eth$i
done
ip netns exec ns6 ip link set up dev br2
#add delay and bw
tc qdisc add dev eth0 handle 1: root htb default 11
tc class add dev eth0 parent 1: classid 1:1 htb rate 10mbps
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 10mbps
tc qdisc add dev eth0 root netem delay 10ms
Alguém pode ajudar?
Se uma interface estiver dentro de um namespace, qualquer comando para operar nessa interface deve ser executado nesse namespace.