I am relatively new to networking so bear with me if you please. I am using Ubuntu 16.04 on an NVIDIA Jetson TX2. I have a Velodyne Lidar VLP-16 Lite connected directly to the Ethernet port and am connected to the internet via wlan0. When I connect to eth0 (AKA the Lidar) while I was still connected to wlan0, I could not ping google. If I disconnected from eth0, internet access came back as I was always connected to wlan0.
First solution
I went into the network manager and modified the eth0 settings to have an ip of 192.168.2.227 and net mask 255.255.255.0. I also edited the IPv4 routes to include Address: 192.168.2.1 and net mask 255.255.255.0 and clicked the radio button "use this connection only for resources on its network".
This allowed me to connect both to the internet via wlan0 and to communicate with the LIDAR peripheral directly via its host IP 192.168.2.201 (which I set).
So What's the Problem? I believe I am losing packets, perhaps randomly.
So what's the question? How do I route everything that is coming from or going to a specific address to a specific interface and make everything else go to the other interface?
That is: How do I make all traffic that is sent to IP address 192.168.2.201 (Me => the LIDAR) to go through eth0, and all traffic to IP address 192.168.2.202 (Lidar => me) go to eth0? All the while making everything else go through wlan0?
Currently my system looks like this:
ubuntu@VPro-test2:~$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
ubuntu@VPro-test2:~$ ip route
default via 192.168.1.1 dev wlan0 proto static metric 600
169.254.0.0/16 dev eth0 scope link metric 1000
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.45 metric 600
192.168.2.0/24 dev eth0 proto kernel scope link src 192.168.2.202 metric 100
ubuntu@VPro-test2:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:04:4b:8c:c1:0c
inet addr:192.168.2.202 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::1a8f:c89c:e32c:8de0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:131110 errors:0 dropped:0 overruns:0 frame:0
TX packets:1494 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:72618144 (72.6 MB) TX bytes:824212 (824.2 KB)
Interrupt:42
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:43 errors:0 dropped:0 overruns:0 frame:0
TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:2467 (2.4 KB) TX bytes:2467 (2.4 KB)
wlan0 Link encap:Ethernet HWaddr 00:04:4b:8c:c1:0a
inet addr:192.168.1.45 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::9679:8dae:defd:aafa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6277 errors:0 dropped:0 overruns:0 frame:0
TX packets:382 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:783723 (783.7 KB) TX bytes:49404 (49.4 KB)
I am looking explicitly for the configuration to enable this, be that command line or graphical interface. Thanks!
Best Answer
I am not an expert, just autodidact. Hopefully this is going to help you somehow, since nobody gave you any answer at all actually.
You believe you are losing packets, perhaps randomly - how to you come to this conclusion?
How do I route everything that is coming from or going to a specific address to a specific interface and make everything else go to the other interface?
By setting up routes as you already did using the gui.
It should work like this from command line:
Ethernetdevice connected to the LIDAR
sudo ip route add ip-of-a-specific-server-or-device-or-of-whole-subnet via standardgateway1
the command could look like this
or if you want to route all traffic to any device inside that subnet:
/24 is a subnetmask of 255.255.255.0 that is 8 bit + 8 bit + 8 bit + 0 bit = 24 bit
Ethernetdevice connected to the internet
sudo ip route add all-the-rest-to-the-internet via standardgateway2
The command should look like this:
Problems that sometimes can occur when routing:
You are sending ip packets with a bad source ip. For example it can happen that you send a source ip of 192.168.1.x to a device at 192.168.2.x. To check this you could use
tcpdump -i interface -vvv
and check what is shown as your outgoing ip. To repair this you need to useiptables
and MASQUERADE your traffic for example withsudo iptables -A POSTROUTING -t nat -o specific-interface-for-example-eth0 -j MASQUERADE
To Monitor your traffic I would suggest to use
bmon
as it will show you also collisions / errors per device.