“模板:WIFI AP”的版本间的差异

来自ARM Wiki
跳转至: 导航搜索
 
(未显示同一用户的6个中间版本)
第1行: 第1行:
:*配置无线热点,需要配置hostapd、dhcpd以及iptables
+
:*配置无线热点,需要配置hostapd、dnsmasq以及iptables
::1、配置/etc/dhcp/dhcpd.conf(使用vi添加以下内容):
+
::1、配置/etc/dnsmasq.conf(使用vi添加以下内容):
 
::<syntaxhighlight lang="bash">
 
::<syntaxhighlight lang="bash">
start 192.168.0.20    //动态分配ip的起始网段
+
interface=wlan0
end 192.168.0.25      //动态分配ip的结束网段
+
bind-interfaces //监听wlan0
interface  wlan0      //实际wifi的节点名
+
except-interface=lo
option subnet  255.255.255.0
+
dhcp-range=192.168.0.100,192.168.0.254,12h //设置dhcp地址范围和租约时间
option router  192.168.0.1
+
dhcp-option=3,192.168.0.1 //设置网关为192.168.0.1
option lease  86400
+
dhcp-option=6,8.8.8.8 //设置DNS为8.8.8.8
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
::2、配置/etc/hostapd/hostapd.conf(使用vi添加以下内容):
 
::2、配置/etc/hostapd/hostapd.conf(使用vi添加以下内容):
 
::<syntaxhighlight lang="bash">
 
::<syntaxhighlight lang="bash">
 +
ssid=norco
 
interface=wlan0
 
interface=wlan0
ieee80211n=1
+
driver=nl80211
ssid=norco              //wifi 热点名称
 
hw_mode=g
 
 
channel=7
 
channel=7
macaddr_acl=0
 
auth_algs=1
 
 
ignore_broadcast_ssid=0
 
ignore_broadcast_ssid=0
 +
hw_mode=g
 +
ieee80211n=1
 
wpa=2
 
wpa=2
wpa_passphrase=12345678     //wifi 热点密码
+
wpa_passphrase=12345678
 
wpa_key_mgmt=WPA-PSK
 
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
+
wpa_pairwise=TKIP CCMP
 
rsn_pairwise=CCMP
 
rsn_pairwise=CCMP
ctrl_interface=/var/run/hostapd
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
::2、开启无线热点(此时会开启一个热点名为”norco”,密码为”12345678”的WiFi热点):
+
::3、开启无线热点(此时会开启一个热点名为"norco",密码为"12345678"的WiFi热点):
 
::<syntaxhighlight lang="bash" line>
 
::<syntaxhighlight lang="bash" line>
 
ifconfig wlan0 up
 
ifconfig wlan0 up
 
ifconfig wlan0 192.168.0.1 netmask 255.255.255.0
 
ifconfig wlan0 192.168.0.1 netmask 255.255.255.0
 
hostapd /etc/hostapd/hostapd.conf -B
 
hostapd /etc/hostapd/hostapd.conf -B
udhcpd -S /etc/udhcpd.conf
+
dnsmasq
 
echo 1 > /proc/sys/net/ipv4/ip_forward
 
echo 1 > /proc/sys/net/ipv4/ip_forward
 
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
 
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
 
</syntaxhighlight>
 
</syntaxhighlight>

2020年6月1日 (一) 16:38的最新版本

  • 配置无线热点,需要配置hostapd、dnsmasq以及iptables
1、配置/etc/dnsmasq.conf(使用vi添加以下内容):
interface=wlan0
bind-interfaces //监听wlan0
except-interface=lo
dhcp-range=192.168.0.100,192.168.0.254,12h //设置dhcp地址范围和租约时间
dhcp-option=3,192.168.0.1 //设置网关为192.168.0.1
dhcp-option=6,8.8.8.8 //设置DNS为8.8.8.8
2、配置/etc/hostapd/hostapd.conf(使用vi添加以下内容):
ssid=norco
interface=wlan0
driver=nl80211
channel=7
ignore_broadcast_ssid=0
hw_mode=g
ieee80211n=1
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
3、开启无线热点(此时会开启一个热点名为"norco",密码为"12345678"的WiFi热点):
1 ifconfig wlan0 up
2 ifconfig wlan0 192.168.0.1 netmask 255.255.255.0
3 hostapd /etc/hostapd/hostapd.conf -B
4 dnsmasq
5 echo 1 > /proc/sys/net/ipv4/ip_forward
6 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE