-
Notifications
You must be signed in to change notification settings - Fork 12
Advanced Linux Networking FAQ
Q: How to test network connection between some applications at one host with full network stack?
A: unshare application! Example:
H = host
C = "container" for app
H: Create pair of linked interfaces. ceth0 -- for host-side, ceth1 -- for app-side:
ip link add name ceth0 type veth peer name ceth1
H: Set IP address for host:
ip a add 172.18.0.1/24 dev ceth0
H: Set host-side interface up:
ip link set dev ceth0 up
H: Isolate bash process from network namespace, (e.g. "create container"):
unshare --net bash
C: Get PID of root process in 'container':
echo $$
H: Dedicate interface ceth1 to 'container', e.g. create point-to-point connection between host and isolated namespace:
ip link set ceth1 netns <PID>
C: Set IP address for application:
ip a add 172.18.0.2/24 dev ceth1
C: Set host-side interface up:
ip link set dev ceth1 up
Q: Multicast is not working if I bind to specified address in Linux
A: Known issue. Should to bind to INADDR_ANY and select correct interface for multicast.
Q: Do I need IP_ADD_MEMBERSHIP prior to IP_ADD_SOURCE_MEMBERSHIP?
A: No. App will be added into group automagically.