Sample Header Ad - 728x90

Capture DNS traffic to and from a network namespace using tshark

3 votes
1 answer
1683 views
How can I capture traffic specifically from a network interface inside a network namespace using tshark? In my case, the network interface tun0 is moved into the network namespace called vpn. Normally running tshark -f "port 53" clutters the output because it includes DNS queries from the main interface that the network namespace ends up using. This is my network namespace setup (for what it's worth, this is from the openvpn netns-up script here: http://www.naju.se/articles/openvpn-netns.html)
$ ip netns add vpn
$ ip netns exec vpn ip link set dev lo up
$ ip link set dev tun0 up netns vpn mtu 1500
$ ip netns exec vpn ip addr add dev tun0 "10.14.0.3/16"

$ ip netns exec vpn ip addr add dev tun0 "$ifconfig_ipv6_local"/112

$ ip netns exec vpn ip route add default via 10.14.0.1

$ ip netns exec vpn ip route add default via "$ifconfig_ipv6_remote"
Asked by EarthIsHome (295 rep)
Mar 19, 2022, 07:18 PM
Last activity: Mar 19, 2022, 11:56 PM