码迷,mamicode.com
首页 > 系统相关 > 详细

ubuntu-mate 搭建无线路由器

时间:2018-07-06 12:18:16      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:cal   nta   install   ubunt   main   ras   禁用   wlan   wifi   

ubuntu-mate 搭建无线路由器**
1.sudo apt update
2.ip addr查看网络信息(有线网卡为eth0, 无线网卡为wlan0)
3.sudo vi /etc/network/interfaces ,输入以下内容后保存。

auto eth0
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet static
address 172.168.1.1
netmask 255.255.255.0
broadcast 172.168.1.255
network 172.168.1.0

4.执行以下脚本禁用NetworkManager后重新启动,
#!/bin/bash
systemctl stop NetworkManager.service
systemctl disable NetworkManager.service
reboot

5.Install hostapd
5.1.sudo apt isntall hostapd
5.2. sudo service hostapd stop
5.3 sudo vi /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=your_wifi_name
hw_mode=g
channel=3
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=your_wifi_password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Save.
5.4 sudo cat >/etc/default/hostapd

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Ctrl +D Save.
5.5 sudo service hostapd restart

6.Install dhcp sudo apt install isc-dhcp-server
6.1 stop dhcp server
sudo service isc-dhcp-server stop
6.2 mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.origin.bak
vi /etc/dhcp/dhcpd.conf

default-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;
}
null

6.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.conf
net.ipv4.ip_forward=1
7.2 sysctl -p
8.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 iptabls
sudo iptables -L -n -v
8.2 Save the rules
sudo 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.

.

ubuntu-mate 搭建无线路由器

标签:cal   nta   install   ubunt   main   ras   禁用   wlan   wifi   

原文地址:http://blog.51cto.com/10108149/2137038

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!