Skip to content

Advanced Linux Networking FAQ

Denis Pynkin edited this page Jul 23, 2015 · 1 revision

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.

Clone this wiki locally