家里没有路由器,于是想用ubuntu搞个热点,目标是通过eth0拨号上网使用wlan0共享,
网上搜到hostapd这个软件 ,记录下我的配置过程:
先安装软件:
sudo apt-get install hostapd udhcpd
创建/etc/hostapd/hostapd.conf
ssid=TPLINK_2222
hw_mode=g
channel=2
interface=wlan0
driver=nl80211
macaddr_acl=0
wpa=2
wpa_passphrase=123456789
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
修改/etc/default/hostapd
<span style="font-size:18px;">DAEMON_CONF="/etc/hostapd/hostapd.conf"</span>
修改/etc/udhcpd.conf
start 192.168.0.20 #default: 192.168.0.20
end 192.168.0.254 #default: 192.168.0.254
interface wlan0
max_leases 20 #default: 254
lease_file /etc/udhcpd.leases
remaining yes
opt dns 202.96.134.133 192.168.0.1
option subnet 255.255.255.0
opt router 192.168.0.1
option lease 864000 # 10 days of seconds
创建/etc/udhcpd.leases
修改/etc/default/udhcpd
DHCPD_ENABLED="yes"
DHCPD_OPTS="-S"
创建脚本ap.sh
#!/bin/sh
sudo ifconfig wlan0 192.168.0.1
sudo service udhcpd start
sudo bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo service hostapd start
执行ap.sh,就可以看到热点了.
注意对于ubuntu14.04,安装2.1版本的hostapd后,需要执行:
sudo nmcli nm wifi off sudo rfkill unblock wlan