1

I'm attempting to connect my Arietta G25 Debian ARM board to my home network using DHCP (or failing that, a static IP in the correct subnet). I'm currently using the board over USB, which shows up as some kind of virtual Ethernet interface which is configured using a static 192.168.10.0/24 IP. I can access it (SSH) from the machine it's plugged into, but I want to be able to access the rest of my network on 192.168.1.0/24 and the internet from the board, as well as access the board from my home network.

The home network is on the 192.168.1.0/24 subnet.

Currently, I have two /etc/network/interfaces files:

Host config (Linux host box)

allow-hotplug usb0
iface usb0 inet static
    address 192.168.10.20
    netmask 255.255.255.0

Board config (Debian ARM board over USB)

auto usb0
iface usb0 inet static
    address 192.168.10.10
    netmask 255.255.255.0
    gateway 192.168.10.20

I've tried setting the board's IP to 192.168.1.90 but that made it unaccessible. Something to do with the gateway perhaps? I've also tried

iface usb0 inet dhcp

to no avail.

How can I get my USB-connected-with-virtual-ethernet-interface ARM board to have an IP address (DHCP or static) on the 192.168.1.0/24 subnet used by the rest of my network when plugged into a box over USB? I'd prefer to use DHCP. There is a DHCP server running on the router on 192.168.1.1.

1

Setting the board's IP to 192.168.1.90 will not work because routing will fail. If you run ip route on the host box, it will show that 192.168.1.0/24 is connected via your normal network connection to the rest of the LAN. It is trying to route packets out that interface and not usb0 as intended.

Two options:

  1. Use the Linux host as a router. This requires enabling forwarding and setting up NAT (MASQUERADING) with iptables (this is actually pretty simple)

  2. Create a bridge interface on your host box and add both of the physical interfaces to that bridge. This is basically like connecting them both to the same switch, but done in software. I will assume your network is connected to the host box on eth0:

    brctl addbr br0
    brctl addif br0 usb0
    brctl addif eth0
    

This should Just Work©. You may need to install the bridge-utils package. Since you're using a Debian-based distro, see here.

  • Thanks for your answer. I tried creating a bridge which unfortunately made the board completely inaccessible for some reason, however I managed to set up some NAT rules in my iptables config which worked – Bojangles Nov 8 '14 at 19:04
  • :). This may not have been your issue, but I also should have added that the bridge would not work over wireless. In any case, glad to hear you got it working. – Greg Bowser Nov 8 '14 at 19:09
1

This is possible using NAT and iptables (thanks to Greg Bowser's answer for inspiration). Assuming eth0 is the network interface and usb0 is the Arietta's network interface, this will set up routing on the host temporarily:

echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o usb0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i usb0 -o eth0 -j ACCEPT

Give it a test (might need to ifdown usb0 and ifup usb0 or reboot the Arietta). If the rules work, you should be able to ping an external address (192.168.1.1 or google.com perhaps) from the Arietta.

If the above iptables rules work, you can make them permanent by adding net.ipv4.ip_forward = 1 to /etc/sysctl.conf and saving the iptables rules. I did this by installing iptables-persistent (apt-get install iptables-persistent) and saving the rules during installation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.