0

I have a laptop running with Ubuntu 15.10. Here there is one integrated Network adapter to which I added another one via USB. I now have two network interfaces which both show when I type ifconfig. Next I configured them both with a static IP: eno0 -> 192.168.0.21 (onboard nic) eno1 -> 192.168.0.22 (USB-nic)

Both adapters are directly to a different destination pc with an Ethernet cable: 192.168.0.21 -> 192.168.0.1 (destination PC 1) 192.168.0.22 -> 192.168.0.2 (destination PC 2)

Next I have a Python script to send UDP packets from the laptop to the destination PC:

import socket
import time
#create socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind("192.168.0.21", 2000)
sock.sendto("test", ("192.168.0.1", 2000))

This works if only one adapter is connected. When both adapters are connected this will only work for the interface that connected first. I then tried to send a ping via the interface not working. Lets say interface eno0 is working and can succesfully send UDP packets via the Python script, then this will not work:

ping -I eno1 192.168.0.2

It show that the packets leave the pc, and via Wireshark I can see them leaving the nic, I can even see the destination PC sending a reply but in the termnial it does not show and when aborting with ctrl+c I see that 5 packets have been send and all of them got lost. Pinging via eno0 works perfectly fine to the destination pc.

How do I fix this?

| improve this question | | | | |
  • 1
    Using multiple network interfaces simultaneously in Linux isn't as straightforward as that. It requires setting up a separated routing table for each of the interface askubuntu.com/a/151966/20381 While you are at that, have a look also at multi-path kernel project – Flint Jan 14 '16 at 13:32
0

I think it works as it is supposed to. I believe you have problems with the routing table.

When you connect the first adapter the default routing is set up through this adapter. When you connect another one, the default routing is already setup for the first adapter. The second adapter does not work because there is no routing that would use it. Try to type /sbin/route of /sbin/route -n. You will see how the packets are routed.

I would add routes for your two connections, because if I understand correctly you only want to send your UDP packets via these connections. What about other traffic? Try it this way:

/sbin/route add -net 192.168.0.1 netmask 255.255.255.255 dev eno0
/sbin/route add -net 192.168.0.2 netmask 255.255.255.255 dev eno1

In that way you specify that traffic for 192.168.0.1 should go via eno0 and traffic for 192.168.0.2 via eno2. If you only need these to connections it should work. However, if you have other connection and want them to work too. You would need to make sure other routes are correct too.

I would recommend to use different address ranges for two connections. In that way you don't need to change routing tables manually:

eno0: 192.168.0.21, PC1: 192.168.0.1
eno1: 192.168.1.22, PC2: 192.168.1.2
netmask: 255.255.255.0 for all connections
default gateway is not important in this case, because pairs are on the same network range
| improve this answer | | | | |
  • This worked for me, thank you very much for your help! – Brilsmurfffje Jan 15 '16 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.