Connect Two Namespaces

Linux lab Intermediate 4 tasks 20 points

Build a tiny network from scratch: two isolated namespaces joined by a virtual cable, each with its own address, able to ping each other. Call them office and branch on the 10.50.0.0/24 network. Everything here needs sudo; password: student.

How it works: the terminal below is a real Linux machine running in your browser. Click it and type. Tasks tick themselves off as you complete them; questions are answered in the box under each task. Press Reset any time for a fresh machine. Your password on this machine (for sudo) is student.

student@vulntech:~ Starting…
Getting your Linux machine ready…
The first start downloads about 20 MB. After that your browser keeps it, and labs start in a moment.

Hints

The steps: add namespaces → add a veth pair → move an end into each → address each end → bring them up → ping.

Each command that touches a namespace runs with sudo ip netns exec NAME ....

Solution explanation

Each ip netns add makes an isolated network stack. A veth pair (veth-o/veth-b) is the virtual cable; moving one end into each namespace and giving both an address on 10.50.0.0/24 puts them on the same network. Once both ends are up, office can ping branch at 10.50.0.2.

Show solution
sudo ip netns add office
sudo ip netns add branch
sudo ip link add veth-o type veth peer name veth-b
sudo ip link set veth-o netns office
sudo ip link set veth-b netns branch
sudo ip netns exec office ip addr add 10.50.0.1/24 dev veth-o
sudo ip netns exec branch ip addr add 10.50.0.2/24 dev veth-b
sudo ip netns exec office ip link set veth-o up
sudo ip netns exec branch ip link set veth-b up
sudo ip netns exec office ip link set lo up
sudo ip netns exec office ping -c2 10.50.0.2
HOME LEARN COMMUNITY DASHBOARD