I am trying to adjust the networking on a system so that two subnets can talk to each (ping) other via a device. Setup looks as follows:

          (  (
Router <------> PC <---------> Device 1 <--------> Device 2
          (    (          (

PC has a DNS Proxy with gateway PC shares its internet to Device 1, and Device 1 shares the internet with Device 2. This is achieved with IP routing, but PC can not ping Device 2. That is also required for my setup. Devices share their internet using USB (cdc_ncm driver).

Routes are as follows:

On PC:

default via dev eno1  proto static  metric 100 via dev usb0 dev usb0  proto kernel  scope link  src dev eno1  proto kernel  scope link  src  metric 100 dev eno1  proto kernel  scope link  src  metric 202

On Device 1:

default via dev eth1 dev usb1 proto kernel scope link src dev eth1 proto kernel scope link src

On Device 2:

default via dev usb0 dev usb0 proto kernel scope link src via dev usb0

Additionaly, usb0 interface on Device 1 has a macvlan interface eth1. While internet connectivity works in this setup, PC can not ping Device 2. However, PC can ping Device 1 and Device 1 can ping Device 2.

To try out things, I have flushed iptables on all devices. I will consider it after I achieve such a connectivity.

Is it possible to make it so that PC can ping Device 2? What am I missing here?

EDIT: All devices already have IP routing enabled. Allow me to rephrase the question to avoid confusion. I want to connect three devices using their physical interfaces (USB). I want all to have internet connection shared from PC, and I want that all devices are able to ping each other. I want have the following:

Physical connections

Device 2 having different subnet does not matter, but without it, internet connection does not work. I need suggestions to achieve this. I have no routers except for the one sharing internet to PC.

  • "What am I missing here?" Well for starters, it seems like you're missing a router between the subnets. – Panki May 17 '19 at 6:54
  • Could you please elaborate? Do you mean that I need to configure Device 1 as router? – mozcelikors May 17 '19 at 7:03
  • Basics of networking. A router is connected to multiple subnets. When a subnet wants to talk to a different one, the router "knows" which packets should go where. – Panki May 17 '19 at 7:07
  • So you mean the actual router device is needed. I thought it would be possible to configure routing on Device 1 to make it act as a router. – mozcelikors May 17 '19 at 7:09
  • Also I have another question: Is it possible make Device 2 on the same subnet so that I don't need a router? At then end I want PC and Device 2 pinging each other. – mozcelikors May 17 '19 at 7:12

Careful with the term "share their internet", usually this involves some kind of NAT (network address translation). I'll assume this is not the case for your setup.

You mention a DNS proxy with, but it's not clear how it is connected to the network. I'll assume a network diagram like this (please correct if my interpretation is wrong):

              |                    |                    |
Router        |                    |                    | --| --|--   |
              |        PC          |       Device 1     |
              |--    | --|   
              |                    |                    |--
              | --|                    |   Device 2
              |      DNS proxy     |                    |
              |                    |                    |

(It's good practice to organize the diagram around subnets). In particular the DNS proxy is not connected to the Router.

This means you need the following routes:

On PC:

default via dev eno1 via dev usb0     # NOT .248 !! dev usb0 dev eno1

On Device 1:

default via dev eth1        # NOT .254 !! dev usb1 dev eth1

On Device 2:

default via dev usb0 dev usb0

You'll also need to enable IP forwarding both on PC and on Device 1 (via echo 1 > /proc/sys/net/ipv4/ip_forward as root, can be made permanent with sysctl etc., google).

I'll ignore the problem with the macvlan for the moment, the first step is to get the routing to work.

With this setup, you should be able to ping between PC, Device 1, and Device 2 in any direction. Test this. To debug, run tcpdump -ni usb0 etc. in a new xterm on all interesting interfaces (so four of those on all three devices). Then you can see where your packets disappear if something is not working. ip route get can also be helpful to find out where the kernel thinks the routing for should go.

  • Hi, Thank you very much for helping. I would like to clear some misinformation on my part. PC involves NAT and routing from eno1 to usb0. Gateway for PC is, but Device 1 uses gateway to be able to reach internet through PC. ( I am also unclear about dnsproxy, sadly) All devices in my setup has access to internet. I want to keep that and be able to ping PC<->Device2. By removing .254 routes I think I won't be able to connect to internet. What do you think? – mozcelikors May 17 '19 at 7:55
  • Also the physical connection on the Device 1 is usb0, which has eth1 as macvlan. But I see it is not included in the routing. Is that intentional? – mozcelikors May 17 '19 at 7:59
  • So which device has, and how is this device configured? If all your devices have access to the internet, how do they get it? Via additional network interfaces? What is their configuration (it would need a default route, wouldn't it)? TL;DR: Can you edit your question with a copy of my network diagram and enter all missing information? – dirkt May 17 '19 at 8:02
  • I will do my best – mozcelikors May 17 '19 at 8:03
  • As I wrote, I left out the macvlan problem, because I didn't understood the details and didn't understood how it was related to the routing problem. A physical USB network adapter should never be a macvlan. So either usb0 is misleading, or something really funny is going on. – dirkt May 17 '19 at 8:04

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.