The Mer Wiki now uses your Mer user account and password (create account on https://bugs.merproject.org/)


Nemo/USBNetworking

From Mer Wiki
< Nemo
Revision as of 12:51, 22 July 2013 by Rainisto (Talk | contribs)

Jump to: navigation, search

Simplified setup instructions

Simplified version should work 99% of the machines and distributions, if you run into troubles, then use old more complicated instructions.

Add following lines to /etc/network/interfaces file on linux side.

 allow-hotplug usb0
 auto usb0
 iface usb0 inet static
         address 192.168.2.14
         netmask 255.255.255.0
         up iptables -A POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE
         up echo 1 > /proc/sys/net/ipv4/ip_forward
         down iptables -D POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE
         down echo 0 > /proc/sys/net/ipv4/ip_forward

Restart network manager for the changes to take effect: "sudo stop network-manager; sudo start network-manager". After that magic should happen when you plug and unplug the cable.

On device side you only optionally need to do following as root "route add default gw 192.168.2.14" if there is no default-gw set already. Default gw should come from /etc/usb-moded/usb-moded.ini automaticly.

Old more complicated instructions

These instructions are tested on Nokia N900/N950/N9 and a host machine that uses NetworkManager (with Gnome 3 interface, but other environments should have similar tools).

To get a stable MAC address, run this as root on the device:

echo options g_ether host_addr=00:11:22:33:44:55 > /etc/modprobe.d/g_ether.conf

Once you plug in the usb cable, what happens on the host side is that NetworkManager will try to configure the interface using DHCP (if the host uses NetworkManager, that is). There's no DHCP available, so the connection will fail. You should tell NetworkManager to use manual configuration:

  1. Open "Network Settings"
  2. Select the right "Wired" connection (the one with "Hardware Address" of 00:11:22:33:44:55).
  3. Go to "Options..."
  4. Open the "IPv4 Settings" tab.
  5. Change the "Method" from "Automatic (DHCP)" to "Manual".
  6. Click "Add" on the "Addresses" section.
  7. Enter "192.168.2.14" as the address and "255.255.255.0" as the netmask. The gateway can be left empty (which means that your host machine won't try to route its own internet data through the device).

Now you can use ssh to connect to the device from the host machine. For making life a bit easier, you can add this snippet to ~/.ssh/config:

Host nemo
        HostName 192.168.2.15
        User nemo

This allows you to just run "ssh nemo" to log in to the device as user nemo.

If you want to set up a full internet connection from the device through the host machine, you'll need to make the host machine a router and set up the name server and routing parameters on the device.

Connect the device with usb cable to your host pc and run following commands

sudo /sbin/ifconfig usb0 up 192.168.2.14
sudo /usr/sbin/iptables -A POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE
sudo /usr/sbin/iptables -P FORWARD ACCEPT
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
# Rest of these are here just to print something that is needed for the device to get routing work.
NAME_SERVER=`cat /etc/resolv.conf | grep "nameserver" | head -1`
echo "echo $NAME_SERVER > /etc/resolv.conf"
echo "route add default gw 192.168.2.14"

Note: for ubuntu users you might find iptables under /sbin

By default device clock starts on year 1970. If you do not modify this, you might get error on zypper:

Error code: Unrecognized error
Error message: SSL certificate problem, verify that the CA cert is OK.

What you need to do is setup the clock straight, e.g. issue this command at host PC:

export DATE=$(date) ; ssh root@192.168.2.15 date -s \"$DATE\"

To change the ip and or add a default gateway this can be achieved by editing /etc/usb-moded/usb-moded.ini

Add a section that looks a bit like this:

[network]
ip = <ip of your fancy>
gateway = <gateway you like>

Network interfaces names

After adding a new connection in network manager, you may find it's called 'eth2'. To rename it in /etc/udev/rules.d/70-persistent-net.rules on host machine, you can optionally edit the 'eth2' name:

# USB device 0x0525:0xa4a2 (usb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:01:10:22:03:30", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

Personal tools