USB Networking/zh cn
From Openmoko
m |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
= Neo1973 side = | = Neo1973 side = | ||
− | == | + | == 命名方式 == |
− | + | 预设的状况下Neo1973拥有usb0界面,被编译到kernel中,做为以太网络装置。 | |
− | + | 在Neo上,如果你想要在网络上使用完整的主机名称,你必须定义你的DNS server。建立 /etc/resolv.conf档案,档案中要包含以下的内容: | |
− | + | ||
nameserver xxx.xxx.xxx.xxx | nameserver xxx.xxx.xxx.xxx | ||
Line 11: | Line 10: | ||
e.g. nameserver 192.168.1.1 | e.g. nameserver 192.168.1.1 | ||
− | + | 因此,你也可以轻松的使用 "ipkg update && ipkg upgrade" 更新 Neo. | |
+ | <br><br> | ||
+ | 更好的方法是编辑: /etc/network/interfaces 并且写入以下的内容:<br><br> | ||
+ | <code> | ||
+ | up echo nameserver 192.168.0.200 >/etc/resolv.conf | ||
+ | </code><br> | ||
+ | 要指定你喜好的DNS server而不是192.168.0.200。 | ||
+ | <br><br> | ||
+ | example: <code>up echo nameserver 4.2.2.2 >/etc/resolv.conf</code> | ||
+ | |||
− | + | 另一个方法是symlink (NOW OBSOLETE?) | |
ln -s /var/run/resolv.conf /etc/resolv.conf | ln -s /var/run/resolv.conf /etc/resolv.conf | ||
− | + | 并且在启动 /etc/network/if-up.d/08setupdns script中写入: | |
#!/bin/sh -e | #!/bin/sh -e | ||
echo nameserver 192.168.0.200 > /var/run/resolv.conf | echo nameserver 192.168.0.200 > /var/run/resolv.conf | ||
− | + | 使用这个方法可以在拨号到GPRS时,正确的从ppp 软件中处理。 | |
== Routing == | == Routing == | ||
− | + | 你必须自额外的流量绕送到因特网上。 若你的计算机是预设的目的地位置,这个流量可以透过你的计算机被绕送出去 (see below)。你可以使用下列方法达到这个目地: | |
− | gateway | + | gateway 192.168.0.200 |
− | + | 在usb0区段中到 /etc/network/interfaces。 | |
= Desktop side = | = Desktop side = | ||
− | == | + | == 手动 == |
− | + | 在连接上了装置之后,modprobe usbnet 模块及设定 usb0 接口 (以root身份): | |
<pre> | <pre> | ||
ifconfig usb0 192.168.0.200 netmask 255.255.255.0 | ifconfig usb0 192.168.0.200 netmask 255.255.255.0 | ||
</pre> | </pre> | ||
− | + | 如果你的 eth0 接口位于同一个 '范围' (e.g. 192.168.0.105) 则你可以进行下面的工作: | |
− | 1. | + | 1. 以下列指令ping Neo装置 |
# ping -I usb0 192.168.0.202 | # ping -I usb0 192.168.0.202 | ||
− | 2. | + | 2. 为Neo加入route: |
# /sbin/route add -host 192.168.0.202/32 dev usb0 | # /sbin/route add -host 192.168.0.202/32 dev usb0 | ||
− | 3 | + | 3 登入 Neo |
# ssh root@192.168.0.202 | # ssh root@192.168.0.202 | ||
− | + | 若你没有必要的模块可以让usb0 运作,请确定你启用了以下的kernel选项: | |
* CONFIG_USB_USBNET | * CONFIG_USB_USBNET | ||
* CONFIG_USB_NET_CDCETHER | * CONFIG_USB_NET_CDCETHER | ||
− | + | 二个选项都可以启动 Device Drivers -> USB support -> USB Network Adapters. For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage]. | |
− | == | + | == 自动化方法 == |
− | + | 自[http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] 取得,由 Marcin 'Hrw' Juszkiewicz张贴。 | |
− | + | ||
− | Edit /etc/network/interfaces | + | === Debian 或相似的系统 === |
+ | Edit /etc/network/interfaces: | ||
<pre> | <pre> | ||
allow-hotplug usb0 | allow-hotplug usb0 | ||
Line 71: | Line 80: | ||
</pre> | </pre> | ||
− | + | === Ubuntu (由Feisty、Gutsy 与Hardy测试) === | |
− | Edit /etc/network/interfaces | + | Edit /etc/network/interfaces: |
<pre> | <pre> | ||
auto usb0 | auto usb0 | ||
Line 85: | Line 94: | ||
</pre> | </pre> | ||
− | + | 若你执行用手动的方式执行 echo 1 > /proc/... 指令,sudo 可能尚嫌不足,接着,你则可以自auso bash执行。 | |
+ | |||
+ | Ubuntu Feisty、Gutsy 及 Hardy 在未挂载时,ifdown 是有臭虫的,也就是说,它只有在系统加载时可以执行。 | ||
+ | |||
+ | 这个臭虫很久之前已回报给ubuntu。因此,不要将这个臭虫夹文件,请在下列位置写入备忘:https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437 | ||
− | |||
One can patch /etc/udev/rules.d/85-ifupdown.rules, editing the two lines at the end of the file: | One can patch /etc/udev/rules.d/85-ifupdown.rules, editing the two lines at the end of the file: | ||
<pre> | <pre> | ||
Line 104: | Line 116: | ||
</pre> | </pre> | ||
− | + | 臭虫内容为LABEL="net_end" ,它被放在错的地方。 | |
− | + | === SuSE === | |
− | + | /etc/sysconfig/network/ifcfg-usb0 | |
+ | # USB configuration for PDAs (openmoko) | ||
+ | IPADDR=192.168.0.200 | ||
+ | NETMASK=255.255.255.0 | ||
+ | STARTMODE=onboot | ||
+ | === Fedora (由FC8测试) === | ||
+ | /etc/sysconfig/network-scripts/ifcfg-usb0 | ||
+ | <pre> | ||
+ | # USB configuration for PDAs (openmoko) | ||
+ | # from http://www.handhelds.org/moin/moin.cgi/UsbNet | ||
+ | DEVICE=usb0 | ||
+ | BOOTPROTO=none | ||
+ | IPADDR=192.168.0.200 | ||
+ | NETMASK=255.255.255.0 | ||
+ | ONBOOT=yes | ||
+ | </pre> | ||
− | + | === Red Hat 或类似套件(在 Workstation 5下测试) === | |
+ | 编辑Edit /etc/sysconfig/network-scripts/net.hotplug: | ||
+ | |||
+ | 在这个指令之后 | ||
<pre> | <pre> | ||
case $INTERFACE in | case $INTERFACE in | ||
# interfaces that are registered after being "up" (?) | # interfaces that are registered after being "up" (?) | ||
</pre> | </pre> | ||
− | + | 加入 | |
− | + | ||
<pre> | <pre> | ||
usb0) | usb0) | ||
Line 128: | Line 157: | ||
</pre> | </pre> | ||
− | + | === Gentoo === | |
+ | * 开启 /etc/conf.d/net 并且加入add: | ||
+ | # Neo1973 | ||
+ | config_usb0=( "192.168.0.200 netmask 255.255.255.0" ) | ||
+ | routes_usb0=( "192.168.0.202/32 via 192.168.0.200" ) | ||
+ | * 建立一个新的init script: | ||
+ | cd /etc/init.d | ||
+ | ln -s net.lo net.usb0 | ||
+ | * 将iptables放入使用: | ||
+ | iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT | ||
+ | iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT | ||
+ | iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 | ||
+ | * 将它们存放在 | ||
+ | /etc/init.d/iptables save | ||
+ | * I如果你希望在预设的情况下绕送: | ||
+ | rc-update add iptables default | ||
+ | * 你必须也通知 kernel,开始传送。建立以下的内容,则可以自动传送: | ||
+ | create /etc/conf.d/net.usb0 as follows | ||
+ | |||
+ | preup() { | ||
+ | echo 1 > /proc/sys/net/ipv4/ip_forward | ||
+ | return 0 | ||
+ | } | ||
+ | |||
+ | postdown() { | ||
+ | echo 0 > /proc/sys/net/ipv4/ip_forward | ||
+ | return 0 | ||
+ | } | ||
− | + | 用这个方法,封包传递将会在NEO连接上的时候开始传送,若关闭,则无法传送。 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | === MacOS X === | |
− | + | 请参考MacOS X[[MacOS_X#USB_Networking|USB Networking 一节]]. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | = Mobile开发= | |
− | + | == 代管DNS请求== | |
− | + | 若你是像我一样,常常搬家,必须透过DHCP连接到不同的网络,你可能会因为经常性的更新Neo 1973的resolv.conft而感到烦恼。 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | 要处理这个问题,如我的安装script,我在NEO USB0端口号的IP地址执行。这表示 Neo /etc/resolv.conf 只包含了: | ||
nameserver 192.168.0.200 | nameserver 192.168.0.200 | ||
− | + | 我的计算机将只会依的 /etc/resolv.conf 代管DNS | |
− | + | ||
− | + | ||
− | + | '''请注意我们只会在usb0界面上执行dns proxy ,因此我们并不会破坏其它的网络联机''' | |
− | + | === 使用 dnrd 代管=== | |
− | === | + | 这个 script 被设定为使用 [http://dnrd.sourceforge.net/ dnrd] 做为 dns proxy。[http://buildhost.automated.it/gta01 script] 及 [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd]的复本可以自我的网站取得。这个 script也可以执行上列的[[USB_Networking#Manual_method]]初始安装。 |
− | + | === 以UDP forwarder代管 === | |
+ | 另一个简单的安装是使用来自http://www.tapor.com/udpf/ 的udp forwarder,它可以用下列指令操作: | ||
udpf-elf\ | udpf-elf\ | ||
Line 193: | Line 220: | ||
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1 | iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1 | ||
− | + | 在这里<tt>192.168.0.1</tt> 是你的gateway的IP。它是最简单的方法,但是不建议这样做。但假设你有像ISP DNS服务一样直接连到网络,则建议这样做,但它无法做到流量调节。 | |
− | = | + | = 连接到电话 = |
− | + | 接着以空白密码连接到 <tt>ssh root@192.168.0.202</tt> 电话。 | |
+ | |||
+ | 注意: 在Openmoko上的ssh daemon (dropbear 0.49) 的程序在传现及离开客端状态有 bug。你会收到的离开状态为255。 | ||
− | |||
===SSH Extras=== | ===SSH Extras=== | ||
− | + | I如果你在PC上键入root@192.168.0.202,编辑 /etc/hosts 并加入一个输入'phone' | |
192.168.0.202 phone | 192.168.0.202 phone | ||
− | + | 接着编辑 edit ~/.ssh/config (或建立它) 并加入 | |
host phone | host phone | ||
user root | user root | ||
− | + | 你必须做的工作是 | |
# ssh phone | # ssh phone | ||
− | + | 要避免 ssh 为每个已知的hostsssh host-key加入新的一行,你可以加下下列的内容到~/.ssh/config | |
UserKnownHostsFile /dev/null | UserKnownHostsFile /dev/null | ||
− | + | 你可能想要使用 key 跳过这个过程。 | |
===SSH Keys=== | ===SSH Keys=== | ||
− | ==== | + | ====从主机到手机==== |
− | + | 要产生可以用的 ssh key 做为登入之用,请输入: | |
ssh-keygen -t rsa | ssh-keygen -t rsa | ||
− | + | 在出现键入密码时,请键入ENTER(''虽然它不是个好主意'')或者是以这个KEY做为密码输入。ssh到手机,并且建立~/.ssh | |
# mkdir ~/.ssh | # mkdir ~/.ssh | ||
− | + | 接着,从你的计算机上复制 '''.pub'''档案到手机上 | |
# scp ~/.ssh/id_rsa.pub phone:.ssh/authorized_keys | # scp ~/.ssh/id_rsa.pub phone:.ssh/authorized_keys | ||
− | + | 你现在应该可以直接 ssh 到手机上 | |
− | + | 要停用登入密码 ('''在设定完KEY存取之后''') 编辑 /etc/init.d/dropbear 并且变更下列的内容 | |
DROPBEAR_EXTRA_ARGS= | DROPBEAR_EXTRA_ARGS= | ||
− | + | 为 | |
DROPBEAR_EXTRA_ARGS="-s" | DROPBEAR_EXTRA_ARGS="-s" | ||
− | + | 你必须重新启动,以让设定生效。 | |
− | ==== | + | ====从手机到主机==== |
− | + | 产生key | |
dropbearkey -t rsa -f id_rsa | dropbearkey -t rsa -f id_rsa | ||
− | + | 输出内容将如下: | |
Will output 1024 bit rsa secret key to 'id_rsa' | Will output 1024 bit rsa secret key to 'id_rsa' | ||
Line 262: | Line 290: | ||
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8 | Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8 | ||
− | + | 复制并贴上以下的内容 (在这个范例当中,以'ssh-rsa' 开始,到主机的 authorized_keys 档案为止 (通常是在 ~/.ssh/). | |
− | + | 从手机,ssh -i: | |
ssh -i id_rsa user@host | ssh -i id_rsa user@host | ||
− | + | 对我来讲,它是行的通的。 I ripped off these instructions from: [[http://forum.openwrt.org/viewtopic.php?pid=53705]] | |
− | === | + | ===透过桌面的GUI SSH=== |
− | + | 如果你必须方过USB取得手机上的GUI,你可以用下面的方式使用SSH: | |
ssh -l root -X -v 192.168.0.202 | ssh -l root -X -v 192.168.0.202 | ||
− | + | 如登入,并且执行openmoko-finger-demo ,它会在桌面开启。要取得横式的检视,请变更桌面的GUI窗口。 | |
− | + | ||
− | + | ||
− | + | ===NEO上的远程程序=== | |
+ | 要让桌面上的程序能在你的NEO上显示,请登入手机: | ||
ssh -l root 192.168.0.202 | ssh -l root 192.168.0.202 | ||
− | + | 执行: | |
DISPLAY=:0 xhost +192.168.0.200 | DISPLAY=:0 xhost +192.168.0.200 | ||
− | + | 之后,你可以关闭ssh session。回到桌上型计算机,执行: | |
DISPLAY=moko:0 xclock | DISPLAY=moko:0 xclock | ||
− | + | 请注意xhost 指令只会允许远程应用程序在 192.168.0.200 存取X server。它允许任何人用桌上型机器存取neo X server。要停用远程应用程序,在NEO上执行: | |
DISPLAY=:0 xhost -192.168.0.200 | DISPLAY=:0 xhost -192.168.0.200 | ||
Line 299: | Line 326: | ||
{{Languages|USB Networking}} | {{Languages|USB Networking}} | ||
− | [[Category:Hardware]] | + | [[Category:Hardware/zh cn]] |
− | [[Category:Implemented]] | + | [[Category:Implemented/zh cn]] |
+ | [[Category:USB/zh cn| ]] |
Latest revision as of 22:18, 20 August 2008
Contents |
[edit] Neo1973 side
[edit] 命名方式
预设的状况下Neo1973拥有usb0界面,被编译到kernel中,做为以太网络装置。 在Neo上,如果你想要在网络上使用完整的主机名称,你必须定义你的DNS server。建立 /etc/resolv.conf档案,档案中要包含以下的内容:
nameserver xxx.xxx.xxx.xxx
e.g. nameserver 192.168.1.1
因此,你也可以轻松的使用 "ipkg update && ipkg upgrade" 更新 Neo.
更好的方法是编辑: /etc/network/interfaces 并且写入以下的内容:
up echo nameserver 192.168.0.200 >/etc/resolv.conf
要指定你喜好的DNS server而不是192.168.0.200。
example: up echo nameserver 4.2.2.2 >/etc/resolv.conf
另一个方法是symlink (NOW OBSOLETE?)
ln -s /var/run/resolv.conf /etc/resolv.conf
并且在启动 /etc/network/if-up.d/08setupdns script中写入:
#!/bin/sh -e echo nameserver 192.168.0.200 > /var/run/resolv.conf
使用这个方法可以在拨号到GPRS时,正确的从ppp 软件中处理。
[edit] Routing
你必须自额外的流量绕送到因特网上。 若你的计算机是预设的目的地位置,这个流量可以透过你的计算机被绕送出去 (see below)。你可以使用下列方法达到这个目地:
gateway 192.168.0.200
在usb0区段中到 /etc/network/interfaces。
[edit] Desktop side
[edit] 手动
在连接上了装置之后,modprobe usbnet 模块及设定 usb0 接口 (以root身份):
ifconfig usb0 192.168.0.200 netmask 255.255.255.0
如果你的 eth0 接口位于同一个 '范围' (e.g. 192.168.0.105) 则你可以进行下面的工作:
1. 以下列指令ping Neo装置
# ping -I usb0 192.168.0.202
2. 为Neo加入route:
# /sbin/route add -host 192.168.0.202/32 dev usb0
3 登入 Neo
# ssh root@192.168.0.202
若你没有必要的模块可以让usb0 运作,请确定你启用了以下的kernel选项:
- CONFIG_USB_USBNET
- CONFIG_USB_NET_CDCETHER
二个选项都可以启动 Device Drivers -> USB support -> USB Network Adapters. For more info see the usbnet driver homepage.
[edit] 自动化方法
自Hotplugging usbnet 取得,由 Marcin 'Hrw' Juszkiewicz张贴。
[edit] Debian 或相似的系统
Edit /etc/network/interfaces:
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
[edit] Ubuntu (由Feisty、Gutsy 与Hardy测试)
Edit /etc/network/interfaces:
auto usb0 iface usb0 inet static address 192.168.0.200 netmask 255.255.255.0 network 192.168.0.0 up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 & up echo 1 > /proc/sys/net/ipv4/ip_forward & up iptables -P FORWARD ACCEPT & down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &
若你执行用手动的方式执行 echo 1 > /proc/... 指令,sudo 可能尚嫌不足,接着,你则可以自auso bash执行。
Ubuntu Feisty、Gutsy 及 Hardy 在未挂载时,ifdown 是有臭虫的,也就是说,它只有在系统加载时可以执行。
这个臭虫很久之前已回报给ubuntu。因此,不要将这个臭虫夹文件,请在下列位置写入备忘:https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437
One can patch /etc/udev/rules.d/85-ifupdown.rules, editing the two lines at the end of the file:
SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start" GOTO="net_end" LABEL="net_start" # Bring devices up and down only if they're marked auto. # Use start-stop-daemon so we don't wait on dhcp ACTION=="add", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}" LABEL="net_end" ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"
臭虫内容为LABEL="net_end" ,它被放在错的地方。
[edit] SuSE
/etc/sysconfig/network/ifcfg-usb0
# USB configuration for PDAs (openmoko) IPADDR=192.168.0.200 NETMASK=255.255.255.0 STARTMODE=onboot
[edit] Fedora (由FC8测试)
/etc/sysconfig/network-scripts/ifcfg-usb0
# USB configuration for PDAs (openmoko) # from http://www.handhelds.org/moin/moin.cgi/UsbNet DEVICE=usb0 BOOTPROTO=none IPADDR=192.168.0.200 NETMASK=255.255.255.0 ONBOOT=yes
[edit] Red Hat 或类似套件(在 Workstation 5下测试)
编辑Edit /etc/sysconfig/network-scripts/net.hotplug:
在这个指令之后
case $INTERFACE in # interfaces that are registered after being "up" (?)
加入
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 iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 echo 1 > /proc/sys/net/ipv4/ip_forward exit 0 ;;
[edit] Gentoo
- 开启 /etc/conf.d/net 并且加入add:
# Neo1973 config_usb0=( "192.168.0.200 netmask 255.255.255.0" ) routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )
- 建立一个新的init script:
cd /etc/init.d ln -s net.lo net.usb0
- 将iptables放入使用:
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24
- 将它们存放在
/etc/init.d/iptables save
- I如果你希望在预设的情况下绕送:
rc-update add iptables default
- 你必须也通知 kernel,开始传送。建立以下的内容,则可以自动传送:
create /etc/conf.d/net.usb0 as follows preup() { echo 1 > /proc/sys/net/ipv4/ip_forward return 0 } postdown() { echo 0 > /proc/sys/net/ipv4/ip_forward return 0 }
用这个方法,封包传递将会在NEO连接上的时候开始传送,若关闭,则无法传送。
[edit] MacOS X
请参考MacOS XUSB Networking 一节.
[edit] Mobile开发
[edit] 代管DNS请求
若你是像我一样,常常搬家,必须透过DHCP连接到不同的网络,你可能会因为经常性的更新Neo 1973的resolv.conft而感到烦恼。
要处理这个问题,如我的安装script,我在NEO USB0端口号的IP地址执行。这表示 Neo /etc/resolv.conf 只包含了:
nameserver 192.168.0.200
我的计算机将只会依的 /etc/resolv.conf 代管DNS
请注意我们只会在usb0界面上执行dns proxy ,因此我们并不会破坏其它的网络联机
[edit] 使用 dnrd 代管
这个 script 被设定为使用 dnrd 做为 dns proxy。script 及 dnrd的复本可以自我的网站取得。这个 script也可以执行上列的USB_Networking#Manual_method初始安装。
[edit] 以UDP forwarder代管
另一个简单的安装是使用来自http://www.tapor.com/udpf/ 的udp forwarder,它可以用下列指令操作:
udpf-elf\ -p=53\ -f=`cat /etc/resolv.conf|awk '$1 == "nameserver"{print $2; exit(0);}'`:53
[edit] Proxying with iptables
Its is possible to forward DNS requests with iptables using the DNAT target
iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1 iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1
在这里192.168.0.1 是你的gateway的IP。它是最简单的方法,但是不建议这样做。但假设你有像ISP DNS服务一样直接连到网络,则建议这样做,但它无法做到流量调节。
[edit] 连接到电话
接着以空白密码连接到 ssh root@192.168.0.202 电话。
注意: 在Openmoko上的ssh daemon (dropbear 0.49) 的程序在传现及离开客端状态有 bug。你会收到的离开状态为255。
[edit] SSH Extras
I如果你在PC上键入root@192.168.0.202,编辑 /etc/hosts 并加入一个输入'phone'
192.168.0.202 phone
接着编辑 edit ~/.ssh/config (或建立它) 并加入
host phone user root
你必须做的工作是
# ssh phone
要避免 ssh 为每个已知的hostsssh host-key加入新的一行,你可以加下下列的内容到~/.ssh/config
UserKnownHostsFile /dev/null
你可能想要使用 key 跳过这个过程。
[edit] SSH Keys
[edit] 从主机到手机
要产生可以用的 ssh key 做为登入之用,请输入:
ssh-keygen -t rsa
在出现键入密码时,请键入ENTER(虽然它不是个好主意)或者是以这个KEY做为密码输入。ssh到手机,并且建立~/.ssh
# mkdir ~/.ssh
接着,从你的计算机上复制 .pub档案到手机上
# scp ~/.ssh/id_rsa.pub phone:.ssh/authorized_keys
你现在应该可以直接 ssh 到手机上
要停用登入密码 (在设定完KEY存取之后) 编辑 /etc/init.d/dropbear 并且变更下列的内容
DROPBEAR_EXTRA_ARGS=
为
DROPBEAR_EXTRA_ARGS="-s"
你必须重新启动,以让设定生效。
[edit] 从手机到主机
产生key
dropbearkey -t rsa -f id_rsa
输出内容将如下:
Will output 1024 bit rsa secret key to 'id_rsa' Generating key, this may take a while... Public key portion is: ssh-rsa AAAAB3Nza[...] Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8
复制并贴上以下的内容 (在这个范例当中,以'ssh-rsa' 开始,到主机的 authorized_keys 档案为止 (通常是在 ~/.ssh/).
从手机,ssh -i:
ssh -i id_rsa user@host
对我来讲,它是行的通的。 I ripped off these instructions from: [[1]]
[edit] 透过桌面的GUI SSH
如果你必须方过USB取得手机上的GUI,你可以用下面的方式使用SSH:
ssh -l root -X -v 192.168.0.202
如登入,并且执行openmoko-finger-demo ,它会在桌面开启。要取得横式的检视,请变更桌面的GUI窗口。
[edit] NEO上的远程程序
要让桌面上的程序能在你的NEO上显示,请登入手机:
ssh -l root 192.168.0.202
执行:
DISPLAY=:0 xhost +192.168.0.200
之后,你可以关闭ssh session。回到桌上型计算机,执行:
DISPLAY=moko:0 xclock
请注意xhost 指令只会允许远程应用程序在 192.168.0.200 存取X server。它允许任何人用桌上型机器存取neo X server。要停用远程应用程序,在NEO上执行:
DISPLAY=:0 xhost -192.168.0.200
Languages: |
English • العربية • Български • Česky • Dansk • Deutsch • Esperanto • Eesti • Español • فارسی • Suomi • Français • עברית • Magyar • Italiano • 한국어 • Nederlands • Norsk (bokmål) • Polski • Português • Română • Русский • Svenska • Slovenčina • Українська • 中文(中国大陆) • 中文(台灣) • Euskara • Català |