# Set country code
country_code=TW
# Name of the Wi-Fi interface
interface=wlan0
# Use the nl80211 driver
driver=nl80211
# Wi-Fi network name
ssid=MoodleBox
# Use the 2.4GHz band
hw_mode=g
# Use channel 11
channel=11
# Enable 802.11n
ieee80211n=1
# Enable WMM
wmm_enabled=1
# Enable 40 MHz channels with short guard interval for 20 Mhz
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
# Accept all MAC addresses
macaddr_acl=0
# Use WPA authentication
auth_algs=1
# Use WPA2
wpa=2
# Use a pre-shared key
wpa_key_mgmt=WPA-PSK
# The network passphrase
wpa_passphrase=moodlebox
# Use AES, instead of TKIP
rsn_pairwise=CCMP
# Enable hostapd_cli
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
interface=wlan0 # Use interface wlan0
listen-address=127.0.0.1 # Explicitly specify the address to listen on
listen-address=10.0.0.1 # Explicitly specify the address to listen on
bind-interfaces # Make sure we aren't sending things elsewhere
server=209.244.0.3 # Forward DNS requests to Level3 DNS
server=209.244.0.4 # Forward DNS requests to Level3 DNS
domain-needed # Don't forward short names
bogus-priv # Don't forward addresses in the non-routed spaces
domain=home # Set private domain name to 'home'
local=/home/ # Don't forward queries for private domain 'home'
expand-hosts # Add private domain name to hostnames
dhcp-range=wifi,10.0.0.100,10.0.0.199,255.255.255.0,12h # Assign IP addresses with12h lease, subnet name 'wifi'
dhcp-option=wifi,6,10.0.0.1 # Set DNS server for subnet wifi
# log-facility=/var/log/dnsmasq.log # Enable log
然後修改 /etc/hosts檔案,更換最後一行,由127.0.0.1開頭,取代為下面的內容:
10.0.0.1 moodlebox
路由配置
修改 /etc/sysctl.conf檔案,取消註釋(或增加)此行
net.ipv4.ip_forward=1
在介面中加入這些行:
$ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
$ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
$ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
$ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
$ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"