Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2388875
  • 博文数量: 384
  • 博客积分: 10193
  • 博客等级: 上将
  • 技术积分: 3785
  • 用 户 组: 普通用户
  • 注册时间: 2005-06-09 18:02
文章分类

全部博文(384)

文章存档

2011年(10)

2010年(29)

2009年(39)

2008年(36)

2007年(43)

2006年(198)

2005年(29)

分类: BSD

2007-12-18 11:00:58

为了让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


阅读(6893) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~