3
votes

I'm working on a project where I want to redirect ethernet traffic through another interface. The setup is as follow:

I have a computer with a working internet connection. I also have a MBED LPC1768 board which I can connect by USB with my computer. I can upload a binary file to this device and run it. For example, I can let it act as a keyboard and send key strokes to the computer. I can also let the device act as a mouse and send mouse events.

Now I want the device to act as an ethernet interface. Since the device is connected using USB, I was thinking about an ethernet-over-USB protocol. I've chosen for the USBCDC-ECM protocol which works on Linux and OS X. When plugging in the device, the device is correctly identified as an ethernet interface. Moreover, I run a DHCP server on the embedded device so the computer gets assigned an IP address. Note that the device does not have a working internet connection to the outside world (the computer does have one).

So the embedded device can capture internet traffic from the computer. When the device gets an packet, I want to analyze the packet, send it back to the computer and have it redirected through the working interface.

So for example, I have a laptop and a working connection on interface wlan0. Now I plug in the device. It gets assigned to interface eth0. eth0 is my preferred interface on the computer so all traffic goes to eth0. I capture this traffic on the device and now I want to send the traffic back to the computer and route it over wlan0 (or any other working interface). So basically, I want to create a device that captures data and send it back to the computer, acting like a middleware USB device for internet traffic.

Is this possible to do? I prefer to not modify settings on the OS and let the device manage it. My primary OS is Ubuntu 14.04 so I do not care about Windows or OS X at the moment. Also, are there any alternatives to do this? Maybe USBCDC-ECM is not the best choice for this.

Any help would be highly appreciated.

3
That question is far to broad. Do you have any specific question about an actual programming problem? What have you tried yourself? Have you tried the NXP forums?too honest for this site
If it is assigned an address, that is a DHCP client not a server.Clifford
Ok, after reading other posts: do you want to have the board itself an internet connection through "another interface" (the LPC1768 has an Ethernet MAC on-chip actually) or the PC to work as a bridge between the board and the i-net? For the latter: that is actually not a programming question, but about administration.too honest for this site
@Clifford true, I've edited it in the question. The computer gets an IP address and the device gives this IP address to the computer.Devos50
@Olaf The board itself does not have a working internet connection. I want it to receive internet requests from the computer, analyze these packets and send them back to the computer but have them routed over a valid interface then.Devos50

3 Answers

1
votes

Configure the host (the computer the MBED board is attached to) for Internet Connection Sharing (ICS), also known as Network Bridging. How that is done depends on the host's OS; for example:

In this scenario, the host is the DHCP server and provides an address to the device; the device itself must then be a DHCP client not a server.

1
votes

I am not sure what you try to accomplish, but if your device already shows as an ethernet connection, can't you use the iptables to redirect traffic to your device?

Else you can let your device act as a DNS server and handle incoming dns lookups and redirect them. Just a wild thought.

0
votes

If you have a Linux OS you can use iptables and inidicate all traffic outside the LAN goes through that interface. That's the correct way to do it.