USB Networking

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (shorter)
(usb networking - Automatic method)
Line 24: Line 24:
 
Took from [http://www.hrw.one.pl/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] post by Marcin 'Hrw' Juszkiewicz.
 
Took from [http://www.hrw.one.pl/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] post by Marcin 'Hrw' Juszkiewicz.
  
Edit /etc/network/interfaces file (in Debian or similiar distros):
+
'''For Debian or similar distros:'''
 +
Edit /etc/network/interfaces file ():
 
<pre>
 
<pre>
 
allow-hotplug usb0
 
allow-hotplug usb0
Line 35: Line 36:
 
         post-up iptables -P FORWARD ACCEPT
 
         post-up iptables -P FORWARD ACCEPT
 
</pre>
 
</pre>
 +
 +
 +
'''For Red Hat or similar distros'''
 +
Edit /etc/sysconfig/network-scripts/net.hotplug:
 +
 +
After this statement:
 +
<pre>
 +
    case $INTERFACE in
 +
# interfaces that are registered after being "up" (?)
 +
</pre>
 +
 +
Add the following:
 +
<pre>
 +
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
 +
;;
 +
</pre>
 +
  
 
And now when you connect phone (which has 192.168.0.202 IP) it gets connection to world automatically.
 
And now when you connect phone (which has 192.168.0.202 IP) it gets connection to world automatically.

Revision as of 06:18, 4 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

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
	;;


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

Connecting to phone

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

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

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
	;;


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

Connecting to phone

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