Primero identificar las interfaces
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether dc:0e:a1:b0:e6:e2 brd ff:ff:ff:ff:ff:ff
inet 169.254.85.18/16 brd 169.254.255.255 scope link noprefixroute enp2s0f0
valid_lft forever preferred_lft forever
inet 192.168.34.1/24 scope global enp2s0f0
valid_lft forever preferred_lft forever
inet6 fe80::269:2be0:6245:9faa/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 44:6d:57:57:4d:e1 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.73/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp3s0
valid_lft 42230sec preferred_lft 42230sec
inet6 fe80::cc69:a48c:a959:dbfd/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: enxd0c0bf2f7343: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether d0:c0:bf:2f:73:43 brd ff:ff:ff:ff:ff:ff
inet 192.168.35.1/24 scope global enxd0c0bf2f7343
valid_lft forever preferred_lft forever
Para el ejemplo utilizaremos:
enp2s0f0 (interface onboard)
enxd0c0bf2f7343 (interface usb->ethernet)
Crear un namespace para cada adaptador:
# ip netns add ns_eth0
# ip netns add ns_eth1
Mover los adaptadores a cada namespace:
# ip link set enp2s0f0 netns ns_eth0
# ip link set enxd0c0bf2f7343 netns ns_eth1
Asignar una dirección IP a cada adaptador:
# ip netns exec ns_eth0 ip addr add dev enp2s0f0 192.168.34.1/24
# ip netns exec ns_eth1 ip addr add dev enxd0c0bf2f7343 192.168.34.2/24
Levantar los adaptadores:
# ip netns exec ns_eth0 ip link set enp2s0f0 up
# ip netns exec ns_eth1 ip link set enxd0c0bf2f7343 up
Iniciamos el servidor iperf en una interfaz específica:
# ip netns exec ns_eth0 iperf -s
Conectamos al servidor por medio de la otra interfaz:
# ip netns exec ns_eth1 iperf -c 192.168.34.1
Volver a estado inicial:
# ip netns del ns_eth0
# ip netns del ns_eth1
Extra.
Todo junto por interfaz...:
Interfaz 0
# ip netns add ns_eth0
# ip link set enp2s0f0 netns ns_eth0
# ip netns exec ns_eth0 ip addr add dev enp2s0f0 192.168.34.1/24
# ip netns exec ns_eth0 ip link set enp2s0f0 up
Interfaz 1
# ip netns add ns_eth1
# ip link set enxd0c0bf2f7343 netns ns_eth1
# ip netns exec ns_eth1 ip addr add dev enxd0c0bf2f7343 192.168.34.2/24
# ip netns exec ns_eth1 ip link set enxd0c0bf2f7343 up
...O Ctrl+c, Ctrl+v friendly :) :
Interfaz 0
# ip netns add ns_eth0 && ip link set enp2s0f0 netns ns_eth0 && ip netns exec ns_eth0 ip addr add dev enp2s0f0 192.168.34.1/24 && ip netns exec ns_eth0 ip link set enp2s0f0 up
Interfaz 1
# ip netns add ns_eth1 && ip link set enxd0c0bf2f7343 netns ns_eth1 && ip netns exec ns_eth1 ip addr add dev enxd0c0bf2f7343 192.168.34.2/24 && ip netns exec ns_eth1 ip link set enxd0c0bf2f7343 up
T.R.
No hay comentarios.:
Publicar un comentario