Why am I getting no output in tcpdump even though there is data being sent and received when using network namespaces?
2
votes
1
answer
573
views
I'm using a fresh minimal Ubuntu server 24.04.1 LTS install.
I run these commands as root to set up networking and do some experiments:
> If you have seen [this post](https://unix.stackexchange.com/q/787076/203214) , it's the same setup but with the ip address
2.3.4.5
assigned to my_veth2
and the routing table entry 1.2.3.0/24
to make sure data can be sent and received from each network namespace.
# Terminal 1
apt install -y netcat-traditional tcpdump
ip netns add ns1
ip netns add ns2
ip link add my_veth1 type veth peer name my_veth2
ip link set my_veth1 up netns ns1
ip link set my_veth2 up netns ns2
ip -n ns1 address add 1.2.3.4 dev my_veth1
ip -n ns1 route add 2.3.4.0/24 dev my_veth1
ip -n ns2 address add 2.3.4.5 dev my_veth2
ip -n ns2 route add 1.2.3.0/24 dev my_veth2
ip netns exec ns2 nc -l -p 8080
then I open 2 more terminals to run tcpdump
in each network namespace:
# Terminal 2
ip netns exec ns1 tcpdump -i my_veth1
# Terminal 3
ip netns exec ns2 tcpdump -i my_veth2
then I open one more last terminal to send data to the netcat server in ns2 from ns1:
# Terminal 4
ip netns exec ns1 nc 2.3.4.5 8080 <<< 'Hello world from network namespace ns1'
Results:
* The message sent from Terminal 4 is printed in Terminal 1, as expected.
* No packets are being shown in either tcpdump. **WHY?**
Asked by Adrian
(249 rep)
Nov 24, 2024, 08:23 PM
Last activity: Nov 24, 2024, 11:25 PM
Last activity: Nov 24, 2024, 11:25 PM