将无线网卡改成WIFI热点( by quqi99 )

作者:张华  发表于:2013-10-16
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明

( http://blog.csdn.net/quqi99 )

1, 配置无线网卡成AP模式
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc
#iwconfig wlan0 channel 1
iwconfig wlan0 key off
iwconfig wlan0 essid quqi99
ifconfig wlan0 up
ifconfig wlan0 192.168.100.1/24 broadcast 192.168.100.255
# iwconfig wlan0
wlan0     IEEE 802.11bg  ESSID:"quqi99"  
          Mode:Ad-Hoc  Frequency:2.412 GHz  Cell: B6:D9:8F:6B:37:23   
          Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off

2, 配置SNAT
   #iptables -A FORWARD -i wlan0 -m mac ! --mac-source e0:ca:94:0d:9e:6a -j DROP
   iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
   echo "1" > /proc/sys/net/ipv4/ip_forward

3, 配置DHCP
 1) 安装,sudo yum install dnsmasq && /etc/init.d/dnsmasq restart
 2) dnsmasq --no-hosts --no-resolv --strict-order --bind-interfaces --interface=wlan0 --except-interface=lo --leasefile-ro --dhcp-range=tag0,192.168.100.0,static,86400s --dhcp-lease-max=256

你可能感兴趣的:(将无线网卡改成WIFI热点( by quqi99 ))