I am a BEGINNER with Ubuntu (Linux). I am trying to create an independant network namespace (that I downloaded here : https://github.com/Lekensteyn/netns) in order to capture Internet traffic without noise. My OS is : "Ubuntu", VERSION="18.04.4 LTS (Bionic Beaver)"

The folder downloaded is called netns. So here are the commands to execute for having the same bug that I had :

In a terminal: [sart network namespace:]

sudo ~/netns/netns 0 start

# ip netns add netns0
# ip link add veth0 type veth peer name veth1
# ip link set veth1 netns netns0
# ip link set veth0 up
# ip addr add dev veth0
# ip netns exec netns0 ip link set veth1 up
# ip netns exec netns0 ip addr add dev veth1
# ip netns exec netns0 ip route add default via dev veth1
# iptables -t nat -A POSTROUTING -o veth0 -j MASQUERADE
# iptables -A FORWARD -i veth0 -j ACCEPT
# iptables -A FORWARD -o veth0 -j ACCEPT
# Done!

[External access]

sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o wlp1s0 -j MASQUERADE
sudo sed -n '/nameserver/!p' /etc/resolv.conf > new_resolv.conf
sudo mv new_resolv.conf /etc/resolv.conf
sudo echo nameserver >> /etc/resolv.conf

net.ipv4.ip_forward = 1

In a other terminal:

[For access to external (LAN or internet) hosts, firefox in my case]

sudo ~/netns/netns 0 exec

Even if firefox would open, we got this error:

2021/03/24 19:03:07 socat[8592] E connect(5, AF=1 "\0/tmp/dbus-6LCOz2lgUY", 23): Connection refused

Can you help me to solve this problem please? Thank you

  • What OS & release are you asking about? This isn't a generic Linux support site (Stack Exchange Unix & Linux provides that function). – guiverc Mar 26 at 10:15
  • Thank you @guiverc for your comment. My OS is : "Ubuntu", VERSION="18.04.4 LTS (Bionic Beaver)" . I made an update. – Doua Hugues Zemi Mar 30 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.