How do you create and enter namespaces by hand?
AdvancedConceptKernel Parameters, Namespaces & cgroups
Answer
sudo unshare --pid --fork --mount-proc --uts --net bash
hostname sandbox; ps aux; ip link # only PID 1 bash and a down loopback
lsns # list namespaces on the host
sudo nsenter -t <pid> -n ss -tlnp # enter a container's net ns only
nsenter -t <container-pid> -n lets you use host tools (tcpdump, ss) inside a container's network namespace without them being installed in the image.
More on Kernel Parameters, Namespaces & cgroups
What is sysctl and how do you make a change persistent?BeginnerWhy does Kubernetes require `net.ipv4.ip_forward=1` and `br_netfilter`?AdvancedAre sysctl settings global, or per namespace?AdvancedWhat are Linux namespaces? List all types.BeginnerHow does a network namespace get connectivity?AdvancedWhat does the user namespace enable?Advanced