本文共 2125 字,大约阅读时间需要 7 分钟。
ubuntu-mate 搭建无线路由器**
1.sudo apt update2.ip addr查看网络信息(有线网卡为eth0, 无线网卡为wlan0)3.sudo vi /etc/network/interfaces ,输入以下内容后保存。auto eth0iface eth0 inet dhcpallow-hotplug wlan0iface wlan0 inet staticaddress 172.168.1.1netmask 255.255.255.0broadcast 172.168.1.255network 172.168.1.0
4.执行以下脚本禁用NetworkManager后重新启动,
#!/bin/bashsystemctl stop NetworkManager.servicesystemctl disable NetworkManager.servicereboot5.Install hostapd
5.1.sudo apt isntall hostapd5.2. sudo service hostapd stop5.3 sudo vi /etc/hostapd/hostapd.confinterface=wlan0driver=nl80211ssid=your_wifi_namehw_mode=gchannel=3wmm_enabled=0macaddr_acl=0auth_algs=1ignore_broadcast_ssid=0wpa=2wpa_passphrase=your_wifi_passwordwpa_key_mgmt=WPA-PSKwpa_pairwise=TKIPrsn_pairwise=CCMP
Save.
5.4 sudo cat >/etc/default/hostapdDAEMON_CONF="/etc/hostapd/hostapd.conf"
Ctrl +D Save.
5.5 sudo service hostapd restart6.Install dhcp ,sudo apt install isc-dhcp-server
6.1 stop dhcp serversudo service isc-dhcp-server stop6.2 mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.origin.bak vi /etc/dhcp/dhcpd.confdefault-lease-time 600;
max-lease-time 7200;option subnet-mask 255.255.255.0;option broadcast-address 172.168.1.255;option routers 172.168.1.1;option domain-name-servers 202.96.128.86,8.8.8.8;#option domain-name "example.com";subnet 172.168.1.0 netmask 255.255.255.0 {
range 172.168.1.100 172.168.1.150;}null6.3 vi /etc/default/isc-dhcp-server
INTERFACES="wlan0"
6.4 restart DHCP service.sudo service isc-dhcp-server start 7.Activationg the IPV4 forward ,change the following line in sysctl.conf
7.1 sudo vi /etc/systcl.confnet.ipv4.ip_forward=1
7.2 sysctl -p8.Changing the Firewall*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
8.1 Check the iptablssudo iptables -L -n -v8.2 Save the rulessudo sh -c "iptables-save > /etc/iptables.ipv4.nat"sudo vi /etc/rc.local#add the follow line before "exit 0"`iptables-restore < /etc/iptables.ipv4.nat*`
Done.
.
转载于:https://blog.51cto.com/10108149/2137038