Linux Network Space - HaymonEdmur/DockerConfiguration GitHub Wiki
Command | Description |
---|---|
ip netns add braintree |
Adds a new network name space braintree |
ip netns list |
Lists all network namespaces |
ip netns del braintree |
Deletes a namespace |
Execute bash in newly added netns. Root space will not be visible from new netns. There will be only one loop back interace. By default there won't be IP address assigned to it and its state will be down
# ip netns exec braintree bash
# ip addr
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
Loop back can be used for IPC with in this netns. Network stack can be added and shared to this netns to communicate > with outer world. All processes can share one IP in this netns and can be connected to its ports from outer world.
# ip addr add 127.0.0.1/24 dev lo
# ip link set lo up
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/24 scope host lo
valid_lft forever preferred_lft forever
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
# ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.029 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.037 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.024 ms
^C
--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.024/0.030/0.037/0.005 ms