Forwarding Ethernet traffic over another interface

I am working on a project where I want to redirect Ethernet traffic over a different interface. The setting is done as follows:

I have a computer with a working internet connection. I also have an MBED LPC1768 board that I can connect via USB with my computer. I can download the binary to this device and run it. For example, I can let it act like a keyboard and send keystrokes to the computer. I can also let the device act like a mouse and dispatch mouse events.

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

Thus, the embedded device can capture internet traffic from the computer. When the device receives a packet, I want to parse the packet, send it back to the computer, and redirect it through the work interface.

So, for example, I have a laptop and a working connection on the interface wlan0

. Now I connect the device. It is assigned to the interface eth0

. eth0

- my preferred interface is on the computer, so all traffic goes to eth0

. I am capturing this traffic on the device and now I want to send traffic to the computer and redirect it to wlan0

(or any other working interface). So basically I want to create a device that grabs data and sends it back to the computer, acting as an intermediate USB device for internet traffic.

Can this be done? I prefer not to change the settings in the OS and not let the device control it. My main OS is Ubuntu 14.04, so I don't care about Windows or OS X at the moment. Also, are there any alternatives for this? Perhaps USBCDC-ECM is not the best choice for this.

Any help would be much appreciated.

+3


source to share


3 answers


I'm not sure what you are trying to accomplish, but if your device is already showing up as an ethernet connection, can you use iptables to redirect traffic to your device?



Alternatively, you can let your device act as a DNS server and handle incoming DNS requests and forward them. Just a wild thought.

+1


source


Configure the host (to the computer to which the MBED is connected) for Internet Connection Sharing (ICS), also called Network Bridging. How this is done depends on the host OS; eg:



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

+1


source


If you have Linux OS, you can use iptables and deny all traffic outside the local network through this interface. This is the correct way to do it.

0


source







All Articles