trying to make local networking experiment, and unable to ping from within the namespaced network.
I'm using Fedora 37.
Linux dmitry-desktop 6.1.18-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 11 16:09:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
I'm getting the following error
➜ sudo ip netns exec netns-test0 ping 10.10.10.11 PING 10.10.10.11 (10.10.10.11) 56(84) bytes of data. From 10.10.10.1 icmp_seq=1 Packet filtered From 10.10.10.1 icmp_seq=2 Packet filtered From 10.10.10.1 icmp_seq=3 Packet filtered
setup
➜ sudo ip netns add netns-test0 ➜ sudo ip netns add netns-test1 ➜ ls -la /var/run/netns total 0 drwxr-xr-x. 2 root root 80 Mar 22 13:42 . drwxr-xr-x. 63 root root 1.7K Mar 22 12:55 .. -r--r--r--. 1 root root 0 Mar 22 13:42 netns-test0 -r--r--r--. 1 root root 0 Mar 22 13:42 netns-test1 ➜ sudo ip link add eth00 type veth peer name eth01 ➜ sudo ip link add eth10 type veth peer name eth11 ➜ sudo ip link set eth00 up ➜ sudo ip link set eth01 up ➜ sudo ip link set eth01 netns netns-test0 ➜ sudo ip link set eth11 netns netns-test1 ➜ sudo ip netns exec netns-test0 ip link set lo up ➜ sudo ip netns exec netns-test0 ip link set eth01 up ➜ sudo ip netns exec netns-test0 ip addr 10.10.10.10/24 dev eth01 Command "10.10.10.10/24" is unknown, try "ip address help". ➜ sudo ip netns exec netns-test0 ip addr add 10.10.10.10/24 dev eth01 ➜ sudo ip netns exec netns-test1 ip link set lo up ➜ sudo ip netns exec netns-test1 ip link set eth11 up ➜ sudo ip netns exec netns-test1 ip addr add 10.10.10.11/24 dev eth11 ➜ sudo ip link add name br0 type bridge ➜ sudo ip addr add 10.10.10.1/24 brd + dev br0 ➜ sudo ip link set br0 up ➜ sudo ip link set eth00 master br0 ➜ sudo ip link set eth10 master br0 ➜ sudo bridge link show br0 20: eth00@if19: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 2 22: eth10@if21: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 2 ➜ sudo iptables -A FORWARD -i br0 -j ACCEPT ➜ sudo ip link set eth00 master br0
so from the root namespace I can ping all devices and br0.
➜ ping 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. 64 bytes from 10.10.10.1: icmp_seq=1 ttl=64 time=0.038 ms 64 bytes from 10.10.10.1: icmp_seq=2 ttl=64 time=0.057 ms ➜ ping 10.10.10.10 PING 10.10.10.10 (10.10.10.10) 56(84) bytes of data. 64 bytes from 10.10.10.10: icmp_seq=1 ttl=64 time=0.047 ms 64 bytes from 10.10.10.10: icmp_seq=2 ttl=64 time=0.060 ms ➜ ping 10.10.10.11 PING 10.10.10.11 (10.10.10.11) 56(84) bytes of data. 64 bytes from 10.10.10.11: icmp_seq=1 ttl=64 time=0.049 ms 64 bytes from 10.10.10.11: icmp_seq=2 ttl=64 time=0.053 ms
but if I start pings from within the namespaced network - I get packet filtered.
➜ sudo ip netns exec netns-test0 ping 10.10.10.10 PING 10.10.10.10 (10.10.10.10) 56(84) bytes of data. 64 bytes from 10.10.10.10: icmp_seq=1 ttl=64 time=0.021 ms ➜ sudo ip netns exec netns-test0 ping 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. 64 bytes from 10.10.10.1: icmp_seq=1 ttl=64 time=0.063 ms 64 bytes from 10.10.10.1: icmp_seq=2 ttl=64 time=0.070 ms ➜ sudo ip netns exec netns-test0 ping 10.10.10.11 PING 10.10.10.11 (10.10.10.11) 56(84) bytes of data. From 10.10.10.1 icmp_seq=1 Packet filtered From 10.10.10.1 icmp_seq=2 Packet filtered From 10.10.10.1 icmp_seq=3 Packet filtered ➜ sudo ip netns exec netns-test1 ping 10.10.10.11 PING 10.10.10.11 (10.10.10.11) 56(84) bytes of data. 64 bytes from 10.10.10.11: icmp_seq=1 ttl=64 time=0.018 ms 64 bytes from 10.10.10.11: icmp_seq=2 ttl=64 time=0.033 ms 64 bytes from 10.10.10.11: icmp_seq=3 ttl=64 time=0.036 ms ➜ sudo ip netns exec netns-test1 ping 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. 64 bytes from 10.10.10.1: icmp_seq=1 ttl=64 time=0.061 ms 64 bytes from 10.10.10.1: icmp_seq=2 ttl=64 time=0.075 ms 64 bytes from 10.10.10.1: icmp_seq=3 ttl=64 time=0.075 ms took 2s ➜ sudo ip netns exec netns-test1 ping 10.10.10.10 PING 10.10.10.10 (10.10.10.10) 56(84) bytes of data. From 10.10.10.1 icmp_seq=1 Packet filtered From 10.10.10.1 icmp_seq=2 Packet filtered From 10.10.10.1 icmp_seq=3 Packet filtered From 10.10.10.1 icmp_seq=4 Packet filtered took 3s ✗ sudo ip netns exec netns-test1 ping 8.8.8.8 ping: connect: Network is unreachable ➜ sudo ip netns exec netns-test0 ping 8.8.8.8 ping: connect: Network is unreachable ➜ sudo ip -all netns exec ip route netns: netns-test1 10.10.10.0/24 dev eth11 proto kernel scope link src 10.10.10.11 netns: netns-test0 10.10.10.0/24 dev eth01 proto kernel scope link src 10.10.10.10 ➜ sudo ip -all netns exec ip route add default via 10.10.10.1 netns: netns-test1 netns: netns-test0 ➜ sudo ip -all netns exec ip route netns: netns-test1 default via 10.10.10.1 dev eth11 10.10.10.0/24 dev eth11 proto kernel scope link src 10.10.10.11 netns: netns-test0 default via 10.10.10.1 dev eth01 10.10.10.0/24 dev eth01 proto kernel scope link src 10.10.10.10 ➜ sudo ip netns exec netns-test0 ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. From 10.10.10.1 icmp_seq=1 Packet filtered From 10.10.10.1 icmp_seq=2 Packet filtered From 10.10.10.1 icmp_seq=3 Packet filtered
my iptables config
➜ _ iptables -L -n -v Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 95 7810 DOCKER-USER all -- * * 0.0.0.0/0 0.0.0.0/0 95 7810 DOCKER-ISOLATION-STAGE-1 all -- * * 0.0.0.0/0 0.0.0.0/0 13 1226 ACCEPT all -- * docker0 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED 0 0 DOCKER all -- * docker0 0.0.0.0/0 0.0.0.0/0 15 956 ACCEPT all -- docker0 !docker0 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT all -- docker0 docker0 0.0.0.0/0 0.0.0.0/0 67 5628 ACCEPT all -- br0 * 0.0.0.0/0 0.0.0.0/0 0 0 all -- * * 0.0.0.0/0 0.0.0.0/0 0 0 all -- * * 0.0.0.0/0 0.0.0.0/0 0 0 all -- * * 0.0.0.0/0 0.0.0.0/0 0 0 all -- * * 0.0.0.0/0 0.0.0.0/0 0 0 all -- * * 0.0.0.0/0 0.0.0.0/0 0 0 all -- * * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT all -- br0 * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT all -- br0 * 0.0.0.0/0 0.0.0.0/0 Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain DOCKER (1 references) pkts bytes target prot opt in out source destination Chain DOCKER-ISOLATION-STAGE-1 (1 references) pkts bytes target prot opt in out source destination 15 956 DOCKER-ISOLATION-STAGE-2 all -- docker0 !docker0 0.0.0.0/0 0.0.0.0/0 95 7810 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 Chain DOCKER-ISOLATION-STAGE-2 (1 references) pkts bytes target prot opt in out source destination 0 0 DROP all -- * docker0 0.0.0.0/0 0.0.0.0/0 15 956 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 Chain DOCKER-USER (1 references) pkts bytes target prot opt in out source destination 95 7810 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
firewalld:
➜ firewall-cmd --list-all FedoraWorkstation (active) target: default icmp-block-inversion: no interfaces: br0 ens1f1 eth01 eth11 vpn0 sources: services: dhcpv6-client mdns samba-client ssh ports: 1025-65535/udp 1025-65535/tcp protocols: forward: no masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: