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...)