I have an evaluation board that has two embedded hosts running Linux with one of them being IMX8 (hostB) while the other being a custom one (let's call it hostA).

Both the hosts are connected over USB, and there's a USB interface coming up in hostB.

  • hostA has rmnet_data0 interface, which is a WAN interface used to talk to the internet.

  • What I am looking to do is be able to receive/send IP packets in hostB through hostA; basically routing the packets coming from ISP to hostA over to hostB.

ISP <-> hostA <-> hostB

rmnet interface on hostA (sorry couldn't copy right now)

// interfaces on hostB
lo        Link encap:Local Loopback
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:152 errors:0 dropped:0 overruns:0 frame:0
          TX packets:152 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:17024 (16.6 KiB)  TX bytes:17024 (16.6 KiB)

usb0      Link encap:Ethernet  HWaddr 1E:C8:CD:E5:74:76
          inet6 addr: fe80::1cc8:cdff:fee5:7476/64 Scope:Link
          RX packets:15 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:880 (880.0 B)  TX bytes:1902 (1.8 KiB)

The interface on hostB doesn't have an IPv4. Would the initial step be to statically assign an IP to it (which perhaps sets the subnet itself?)

I have seen some articles/threads like this that use IP tables but they seem to be using ports which I'm uncertain of.

Though after reading up a bit, would the following on hostA suffice?

iptables -t nat -A PREROUTING -d rmnet_data2 -j DNAT --to-destination usb0

Edit: so upon setting a static IP to usb0, I see it generated a subnet value which is the same as that of bridge0, and I could ping both ways. Would the idea be to route the packets from hostB to hostA through bridge0?

New contributor
Jazzy is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Iptables is an interface to the kernel packet filter. It doesn't directly do any routing. And, please, specify all IP addresses (with netmasks) of all network devices, SoCs and the "ISP" system, for us to be able to figure out which routing you need. – Nikita Kipriyanov Apr 7 at 7:01
  • I have specified the only interface (LO) that was missing on socB – Jazzy Apr 8 at 2:43
  • You have drawn (a pretty simple) network diagram: ISP <-> hostA <-> hostB. Now, please specify all four addresses with netmasks and NIC names: ISP, hostA towards ISP, hostA towards hostB and hostB. Again, the rule you suggested in the end is invalid, and even if you make it valid (by using some IP address instead of NIC name in --to-destination), likely it won't help either. You need to set up routing, not address translation, don't you? It is done with the ip tool, an iptables doesn't have a direct relation to this. – Nikita Kipriyanov Apr 9 at 8:45
  • the IP addresses are already mentioned in the description unless you're referring to something else. In order to talk to the internet, I'd definitely need address translation on host A but for getting packets from host B over to host A, I probably just need routing yes – Jazzy Apr 9 at 21:43
  • No, the only IPv4 address in your post is a loopback, while I ask for addresses assigned to other interfaces. I got that you don't have an address on hostB, but then you must first decide which network you need there. Where is bridge in your diagram? Bridging is done on OSI Layer 2 and it does not have anything in common with routing which is Layer 3 thing. Bridging will effectively change a network (L3) diagram and so which addresses you'd assign and where. You must complete bridging design before you start with assigning IP addresses. – Nikita Kipriyanov yesterday

Browse other questions tagged or ask your own question.