主要工具:
iw : A new nl80211 based CLI configuration utility for wireless
devices.

hostapd : A user space software access point capable of
turning normal network interface cards into access points and
authentication servers.

iptables : Used to set up, maintain, and inspect the tables of IPv4 packet filter rules in the Linux kernel.

udhcpd : A very small DHCP server program geared towards embedded systems.

udhcpc : A very small DHCP client program geared towards embedded systems.

macchanger : A GNU/Linux utility for viewing/manipulating the MAC address of network interfaces.

安装方法:
sudo apt-get install iw hostapd iptables udhcpd udhcpc macchanger

各工具配置文件:
/etc/hostapd.conf

interface=new1
driver=nl80211
ssid=xxxxxxxxx
channel=11 #I sugest you to use the same channel as your wireless network
hw_mode=g
wme_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=xxxxpasswordxxxxx
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

/etc/udhcpd.conf

start 192.168.0.102 #These IPs must to be in the same subset as your current default route
end 192.168.0.117

interface new1

opt dns 114.114.114.114
option subnet 255.255.255.0
opt router 192.168.0.101 #This IP must to be in the same subset as your current default route
option domain localhost

/etc/default/udhcpd

# Comment the following line to enable
#DHCPD_ENABLED="no"

# Options to pass to busybox' udhcpd.
#
# -S Log to syslog
# -f run in foreground

DHCPD_OPTS="-S"

/etc/wpa_supplicant.conf
ctrl_interface=/run/wpa_supplicant
network={
ssid="CMCC-EDU"
key_mgmt=NONE
}

启动 & 关闭 热点 脚本:

启动热点 脚本:

#!/bin/bash

service network-manager stop
sleep 1

pkill -15 nm-applet
sleep 1

ifconfig wlan0 down #wlan0 – the name of your wireless adapter
sleep 1

iw phy phy0 interface add new0 type station
iw phy phy0 interface add new1 type __ap
sleep 2

macchanger –mac 00:11:22:33:44:55 new0
macchanger –mac 00:11:22:33:44:66 new1
ifconfig new1 192.168.0.101 up #192.168.0.101 – the same IP defined for router in ‘udhcpd.conf’ file
hostapd /etc/hostapd.conf &
sleep 2

service udhcpd start

wpa_supplicant -i new0 -c /etc/wpa_supplicant.conf &
sleep 10

udhcpc -i new0

echo “1” /proc/sys/net/ipv4/ip_forward
iptables –table nat –append POSTROUTING –out-interface new0 -j MASQUERADE
iptables –append FORWARD –in-interface new1 -j ACCEPT

关闭热点 脚本:

#!/bin/bash

killall wpa_supplicant
killall hostapd
service udhcpd stop
iw dev new0 del
iw dev new1 del

ifconfig wlan0 up
route add -net 0.0.0.0/0 netmask 0.0.0.0 dev wlan0

iptables --table nat --delete POSTROUTING --out-interface new0 -j MASQUERADE
iptables --delete FORWARD --in-interface new1 -j ACCEPT

service network-manager start
nm-applet &

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据