USB Networking

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (Manual method: Added list of kernel config options needed to get the usbnet drivers needed)
m (Manual method: Removed unnecessary kernel config option CONFIG_USB_NET_CDC_SUBSET)
Line 22: Line 22:
 
If you don't have the necessary modules to get usb0 going, make sure you have the following kernel options enabled:
 
If you don't have the necessary modules to get usb0 going, make sure you have the following kernel options enabled:
 
* CONFIG_USB_USBNET
 
* CONFIG_USB_USBNET
* CONFIG_USB_NET_CDC_SUBSET
 
 
* CONFIG_USB_NET_CDCETHER
 
* CONFIG_USB_NET_CDCETHER
All three options are available in the Device Drivers -> USB support -> USB Network Adapters. For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].
+
Both options are available in the Device Drivers -> USB support -> USB Network Adapters. For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].
  
 
== Automatic method ==
 
== Automatic method ==

Revision as of 20:02, 11 August 2007

Contents

Neo1973 side

By default Neo1973 has usb0 interface working due to Ethernet gadget (g_ether) compiled into kernel.

Desktop side

Manual method

Modprobe usbnet module and configure usb0 interface (as root):

ifconfig usb0 192.168.0.200 netmask 255.255.255.0

If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:

1. ping the Neo with

# ping -I usb0 192.168.0.202

2. add a route to your Neo:

# /sbin/route add -host 192.168.0.202/32 dev usb0

3 log in to the Neo

# ssh root@192.168.0.202

If you don't have the necessary modules to get usb0 going, make sure you have the following kernel options enabled:

  • CONFIG_USB_USBNET
  • CONFIG_USB_NET_CDCETHER

Both options are available in the Device Drivers -> USB support -> USB Network Adapters. For more info see the usbnet driver homepage.

Automatic method

Took from Hotplugging usbnet post by Marcin 'Hrw' Juszkiewicz.

For Debian or similar distros: Edit /etc/network/interfaces file ():

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


For Red Hat or similar distros Edit /etc/sysconfig/network-scripts/net.hotplug:

After this statement:

    case $INTERFACE in
	# interfaces that are registered after being "up" (?)

Add the following:

	usb0)
		ifconfig usb0 192.168.0.200 netmask 255.255.255.0
		route add 192.168.0.202 usb0
		iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT
		iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT
		exit 0
	;;

For Gentoo or similar distros:

  • Edit /etc/conf.d/net by adding:
   # Neo1973
   config_usb0=( "192.168.0.200 netmask 255.255.255.0" )
  • Create a new init script:
   # cd /etc/init.d
   # ln -s net.lo net.usb0

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

For MacOS X:

there are no files to edit since hotplugging configuration is done automatically by default. Of course, the interface has been initialized once. Install the AJZaurusUSB driver as described on MacOS_X and then open System Preferences / Networks which will show the new interface. Configure for Manual DHC with Host address 192.168.0.200 and Gateway 192.168.0.202.

Connecting to phone

Then ssh root@192.168.0.202 with empty password to get into phone.

SSH Extras

If you get fed up with typing root@192.168.0.202, on your PC edit /etc/hosts and add an entry for 'phone'

192.168.0.202 phone

then edit ~/.ssh/config (or create it) and add

host phone
user root

then all you need to do is type

# ssh phone

You might want to use keys to bypass the login prompt too.

SSH Keys

To generate ssh keys for use as a login mechanism type

ssh-keygen -t rsa

when prompted for a password either hit enter for no password (not really a good idea) or enter a password for this key. ssh into the phone and create ~/.ssh

# mkdir ~/.ssh

then from your PC copy the .pub file to the phone.

# scp ~/.ssh/id_rsa.pub phone:.ssh/authorized_keys

You should now be able to ssh directly into the phone.

To disable password logins (after setting up key access) edit /etc/init.d/dropbear and change the following line:

DROPBEAR_EXTRA_ARGS=

to

DROPBEAR_EXTRA_ARGS="-s"

You will need to restart dropbear for this to take effect.

GUI on desktop through SSH

If you need to get the GUI on the phone onto the desktop via usb, you can use ssh as follows

 ssh -l root -X -v 192.168.0.202

Login, and run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.

Personal tools

Neo1973 side

By default Neo1973 has usb0 interface working due to Ethernet gadget (g_ether) compiled into kernel.

Desktop side

Manual method

Modprobe usbnet module and configure usb0 interface (as root):

ifconfig usb0 192.168.0.200 netmask 255.255.255.0

If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:

1. ping the Neo with

# ping -I usb0 192.168.0.202

2. add a route to your Neo:

# /sbin/route add -host 192.168.0.202/32 dev usb0

3 log in to the Neo

# ssh root@192.168.0.202

If you don't have the necessary modules to get usb0 going, make sure you have the following kernel options enabled:

  • CONFIG_USB_USBNET
  • CONFIG_USB_NET_CDCETHER

Both options are available in the Device Drivers -> USB support -> USB Network Adapters. For more info see the usbnet driver homepage.

Automatic method

Took from Hotplugging usbnet post by Marcin 'Hrw' Juszkiewicz.

For Debian or similar distros: Edit /etc/network/interfaces file ():

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


For Red Hat or similar distros Edit /etc/sysconfig/network-scripts/net.hotplug:

After this statement:

    case $INTERFACE in
	# interfaces that are registered after being "up" (?)

Add the following:

	usb0)
		ifconfig usb0 192.168.0.200 netmask 255.255.255.0
		route add 192.168.0.202 usb0
		iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT
		iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT
		exit 0
	;;

For Gentoo or similar distros:

  • Edit /etc/conf.d/net by adding:
   # Neo1973
   config_usb0=( "192.168.0.200 netmask 255.255.255.0" )
  • Create a new init script:
   # cd /etc/init.d
   # ln -s net.lo net.usb0

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

For MacOS X:

there are no files to edit since hotplugging configuration is done automatically by default. Of course, the interface has been initialized once. Install the AJZaurusUSB driver as described on MacOS_X and then open System Preferences / Networks which will show the new interface. Configure for Manual DHC with Host address 192.168.0.200 and Gateway 192.168.0.202.

Connecting to phone

Then ssh root@192.168.0.202 with empty password to get into phone.

SSH Extras

If you get fed up with typing root@192.168.0.202, on your PC edit /etc/hosts and add an entry for 'phone'

192.168.0.202 phone

then edit ~/.ssh/config (or create it) and add

host phone
user root

then all you need to do is type

# ssh phone

You might want to use keys to bypass the login prompt too.

SSH Keys

To generate ssh keys for use as a login mechanism type

ssh-keygen -t rsa

when prompted for a password either hit enter for no password (not really a good idea) or enter a password for this key. ssh into the phone and create ~/.ssh

# mkdir ~/.ssh

then from your PC copy the .pub file to the phone.

# scp ~/.ssh/id_rsa.pub phone:.ssh/authorized_keys

You should now be able to ssh directly into the phone.

To disable password logins (after setting up key access) edit /etc/init.d/dropbear and change the following line:

DROPBEAR_EXTRA_ARGS=

to

DROPBEAR_EXTRA_ARGS="-s"

You will need to restart dropbear for this to take effect.

GUI on desktop through SSH

If you need to get the GUI on the phone onto the desktop via usb, you can use ssh as follows

 ssh -l root -X -v 192.168.0.202

Login, and run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.