http://blog.chinaunix.net/u/7667/showart_444813.html
为了让iphone在没有无线路由的情况下连接到Linux, 我写了一段小脚本, 用来给Linux建立一个Ad-Hoc无线网络. 这个脚本也可以用于别的机器, 通过Ad-Hoc网络连接到Linux.
#!/bin/bash
WLAN_INTERFACE=wlan0
#configure wlan encrypt key
iwconfig $WLAN_INTERFACE enc s:0987654321abc [1]
iwconfig $WLAN_INTERFACE enc open [1]
iwconfig $WLAN_INTERFACE mode ad-hoc
#configure wlan essid, then ur iphone may found it. `
iwconfig $WLAN_INTERFACE essid "iplin"
ifconfig $WLAN_INTERFACE up
#configure ip address for wlan interface, this ip address will be used as iphone's gateway.
ifconfig $WLAN_INTERFACE 192.168.3.1
#configure ur linux box as a router.
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.3.1/24 -j MASQUERADE