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:127.0.0.1 Mask:255.0.0.0
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
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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?
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 theip
tool, aniptables
doesn't have a direct relation to this. – Nikita Kipriyanov Apr 9 at 8:45