3

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.

Devos50
  • 2,025
  • 4
  • 25
  • 56
  • 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 May 29 '15 at 19:15
  • If it is assigned an address, that is a DHCP *client* not a *server*. – Clifford May 31 '15 at 08:03
  • 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 May 31 '15 at 13:42
  • @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 May 31 '15 at 20:02
  • @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 May 31 '15 at 20:04
  • I think the key here, and what you have not explained is *what is* connected to the Internet? If it is the PC, then that should be the DHCP server. If it is the device, then that needs to act as a router and perform NAT; but you have stated that the device "has no internet connection". – Clifford May 31 '15 at 21:56
  • Note that you have quite some traffic to drop coming from the PC (had that problem right now with Linux host). Autoconf, dhcp and IPv6 are quite some blabbermouths on the line, filling the rare buffers rapidly. – too honest for this site May 31 '15 at 22:33
  • Sounds to me like a spy-device (e.g. packet sniffer; adding what you wrote about getting/sending keystrokes and mouse events ... sums up) if you do not want to change the host for that. However, that will not work without help from the host, as that has to 1) redirect regular traffic from wlan0 (or other default interface) to the device and 2) forward the returned (sniffed? manipulated?) frames to the regular interface. However, even if I would know, I will not help, as that sounds too suspicious to me. – too honest for this site Jun 05 '15 at 01:57
  • why not try serial over ethernet instead ? I have done this in a project before and there are a free program called comm tunnel that opens the connection and captures the traffic www.serialporttool.com/CommTunnel.htm – Jay Shenawy Jun 05 '15 at 20:46

3 Answers3

1

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.

Clifford
  • 88,407
  • 13
  • 85
  • 165
1

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.

Gooey
  • 4,740
  • 10
  • 42
  • 76
0

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.

rodolk
  • 5,606
  • 3
  • 28
  • 34
  • Linux on ARM Cortex-M MCU? Good one! – too honest for this site May 31 '15 at 03:29
  • @Olaf; it is not clear in the question, but perhaps it is the host that requires configuration and that *may* be running Linux. – Clifford May 31 '15 at 07:45
  • @Clifford: I re-read the question: yes, that might be true. I did interpret it as if by "right interface" and "another interface" the board itself was meant. However, as he has not clarified that (maybe he tried to config his PC and lost i-net?), it's all speculative. – too honest for this site May 31 '15 at 13:35
  • The computer runs on an Linux OS. The embedded device (an LPC1768) does not run Linux and runs a binary I can compile myself. – Devos50 May 31 '15 at 20:05
  • @Devos50: It was pretty clear the LPC does not run Linux, as that is just hardly possible on that hardware (is ucLinux still active?). You should edit your question to include more information. It's likely not the LPC, but the PC. What you likely want is "reverse tethering" just search for this (that is also used for android devices). Also correct that part on DHCP server. That would be your Linux PC. – too honest for this site May 31 '15 at 22:35