0

I have a 20-ports switch connected to a 20-NICs PC (1-to-1) and want to load it with traffic. Of course configuring all NICs with different IPs and start my client/server (Python3) scripts (or iperf3) will generate local traffic only unless I force the traffic out through the NICs.

I found (here) the two main 'tricks' in order to achieve this:

a.) Using network namespace:

[+] It Will do exactly what I want by isolating (VM/docker-like) each NIC into a box

[+] Python3 seem to support netns (Pyroute2)

[-] Not sure how I can open a socket into a netns/python thread (10 threads x 2 (client/server) )

b.) Using a ghost IP (iptable: S/D-NAT + pre/post-routing):

[+] All NICs remain in the root network namespace (still get to collect data through psutil) and configure at global level

[+] Python TCP threaded script can run wihtout specific lib/support for netns

[-] In case of reconfiguration of my setup (IPs, VLAN,...), IPTable script must be adapted accordingly.

I would like to know if I overlook another possibility here and/or if for a.) I am getting it (all) wrong (since I can't find a decent example with a socket opened in a single Python script over different netns...)

bli
  • 93
  • 6
  • Provide a working example (js-fiddle) for better understanding and more clarity to your question. – SatAj Apr 23 '18 at 23:07
  • Sorry, obviously wrong stack exchange site: moved (and almost answered) here https://superuser.com/questions/1317355/linux-force-packet-to-egress-and-avoid-local-kernel-trafic Please delete this for me. – bli Apr 27 '18 at 18:25
  • @bli Since you are the owner of the question, you can delete it yourself (using the delete option at the bottom of the question) – Bruno Rijsman Dec 18 '18 at 13:47

0 Answers0