Hotpluging usbnet

USB Networking is not my preferred way of networking but it is quite usable with palmtops or Neo1973 phone (which spend most of time connected to USB due to charging problems in GTA01Bv3). But this also has some problems due to fat that this is hotplugable:

  • each plug mean usbX device re-appear
  • no idea which usbX it will be this time

Today I moved my Zaurus c7x0 back to using WiFi so second problem disappeared for me (now only Neo1973 is connected over USB) but first problem was still present. I was tired to having to write sudo ifdown usb0;sudo ifup usb0 each time when I reconnected phone so after reading some man pages I updated my /etc/network/interfaces with this:

allow-hotplug usb0
iface usb0 inet static
        post-up iptables -A POSTROUTING -t nat -j MASQUERADE -s
        post-up echo 1 > /proc/sys/net/ipv4/ip_forward
        post-up iptables -P FORWARD ACCEPT

And now when I connect phone (which has IP) it gets connection to world automatically.

6 thoughts on “Hotpluging usbnet”

  1. You should look into creating a udev rule for the openmoko, it’s usually pretty straightforward.

    It’d be great if you had that up on the wiki by the time I got my phone 😉

  2. Adam: I think that udev rule will be overkill for this task. But now since Neo1973 has other VendorId/ProductId then standard USB gadget system will know that this is Neo and not some other device.

    But what to do when more then one Neo1973 is connected to machine? I had such situation and will have them soon.

  3. Ah well you could always send me any extra phone you got to keep things simple for you.

    But you should be able to poke about the device entry in /sys for a serial number and create a mapping for each device you add.

  4. Definitely entering a udev rule is the way to go… this will be literally one (or maybe two) lines of text, and yields uniqueness for the device. My suggestion would be to map them such that your own phone is like /dev/moko0, then let additional phones enumerate themselves as they are added (these features, too, are available within udev).

Comments are closed.