Eu escrevi um pequeno script que mostra o uso de exemplo de ip netns no tamanho de classe C não utilizado (aqui mudou para 192.168.10)
#!/bin/sh
network=192.168.10
for id in 'seq 0 127'; do
ip netns del test-$id;
done;
bring(){
set -x
idprev=$1
id=$2
ipprev=$(( $idprev * 2 ))
ip=$(( $idprev * 2 + 1 ))
ip netns add test-$id
ip netns exec test-$id ip link set dev lo up
ip netns exec test-$id sysctl -w net.ipv4.conf.default.forwarding=1
ip netns exec test-$id sysctl -w net.ipv4.conf.default.hop_limit=255
ip link add test-$1-$2 type veth peer name test-$2-$1
[ $idprev -eq 0 ] && ip link set test-$1-$2 up
[ $idprev -eq 0 ] && ip a a ${network}.$ipprev/31 dev test-$1-$2
[ $idprev -eq 0 ] && ip r a ${network}.0/24 via ${network}.$ip
[ $idprev -gt 0 ] && ip link set test-$1-$2 netns test-$idprev up
[ $idprev -gt 0 ] && ip netns exec test-$idprev ip a a ${network}.$ipprev/31 dev test-$1-$2
[ $idprev -gt 0 ] && ip netns exec test-$idprev ip r a ${network}.0/24 via $network.$ip
ip link set test-$2-$1 netns test-$id up
ip netns exec test-$id ip a a ${network}.$ip/31 dev test-$2-$1
ip netns exec test-$id ip r a default via ${network}.$ipprev
}
for id in 'seq 0 127'; do
bring $id $(( $id + 1 ))
done;
Eu corri, criei namespaces - então eu tento testá-lo. No pequeno "intervalo" - funciona bem:
undefine@uml:~$ mtr -n -r -c1 192.168.10.10
Start: Sat Apr 4 00:16:25 2015
HOST: uml Loss% Snt Last Avg Best Wrst StDev
1.|-- 192.168.50.253 0.0% 1 1.1 1.1 1.1 1.1 0.0
2.|-- 192.168.51.9 0.0% 1 3.1 3.1 3.1 3.1 0.0
3.|-- 192.168.52.32 0.0% 1 3.5 3.5 3.5 3.5 0.0
4.|-- 192.168.10.1 0.0% 1 4.2 4.2 4.2 4.2 0.0
5.|-- 192.168.10.3 0.0% 1 2.8 2.8 2.8 2.8 0.0
6.|-- 192.168.10.5 0.0% 1 3.6 3.6 3.6 3.6 0.0
7.|-- 192.168.10.7 0.0% 1 10.9 10.9 10.9 10.9 0.0
8.|-- 192.168.10.10 0.0% 1 3.1 3.1 3.1 3.1 0.0
Mas - quando eu tento alcançar saltos posteriores - eu não recebi o icmp respons. Parece algum tipo de limite icmp:
undefine@uml:~$ mtr -n -r -c10 192.168.10.100
Start: Sat Apr 4 00:19:09 2015
HOST: uml Loss% Snt Last Avg Best Wrst StDev
1.|-- 192.168.50.253 0.0% 10 2.2 1.3 0.8 2.2 0.0
2.|-- 192.168.51.9 0.0% 10 3.0 3.4 2.7 4.0 0.0
3.|-- 192.168.52.32 0.0% 10 4.9 3.9 2.7 7.7 1.4
4.|-- 192.168.10.1 90.0% 10 2.7 2.7 2.7 2.7 0.0
5.|-- 192.168.10.3 90.0% 10 2.9 2.9 2.9 2.9 0.0
6.|-- 192.168.10.5 90.0% 10 3.3 3.3 3.3 3.3 0.0
7.|-- 192.168.10.7 90.0% 10 3.6 3.6 3.6 3.6 0.0
8.|-- 192.168.10.9 90.0% 10 4.3 4.3 4.3 4.3 0.0
9.|-- 192.168.10.11 80.0% 10 5.6 4.7 3.7 5.6 1.0
10.|-- 192.168.10.13 50.0% 10 7.0 5.8 2.5 12.0 3.8
11.|-- 192.168.10.15 80.0% 10 2.8 3.3 2.8 3.7 0.0
12.|-- 192.168.10.17 90.0% 10 3.1 3.1 3.1 3.1 0.0
13.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0
14.|-- 192.168.10.21 90.0% 10 3.5 3.5 3.5 3.5 0.0
15.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0
pmp icmp normais - funciona bem com todos os hosts:
undefine@uml:~/filmy$ ping 192.168.10.100
PING 192.168.10.100 (192.168.10.100) 56(84) bytes of data.
64 bytes from 192.168.10.100: icmp_seq=1 ttl=12 time=3.68 ms
64 bytes from 192.168.10.100: icmp_seq=2 ttl=12 time=5.73 ms
64 bytes from 192.168.10.100: icmp_seq=3 ttl=12 time=2.85 ms
^C
--- 192.168.10.100 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 2.851/4.090/5.733/1.211 ms
firewall está vazio, conntrack está desligado, no dmesg não há nada .. em todo namespace eu vejo o fluxo de pacotes icmp echo com ttl diminuído. Eu tentei definir net.ipv4.icmp_ratelimit para vários valores - de 0, 1 para grandes números. Mas isso não ajudou. Eu acho que ainda existe um limite para as respostas icmp do linux. Mas - onde pode ser?