router update

This commit is contained in:
light 2018-01-03 17:10:42 +08:00
parent f0feebf529
commit 876721cd37
3 changed files with 78 additions and 4 deletions

53
raspberry/router.md Normal file
View File

@ -0,0 +1,53 @@
# 用树莓派做路由器
## 网络配置
wlan0 连接公网并将网络共享给有线网和wlan1
``` bash
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
auto wlan0
iface wlan0 inet dhcp
wpa_conf /etc/wpa_supplicant/wpa_supplicant.conf
auto wlan1
iface wlan1 inet static
address 192.168.2.1
netmask 255.255.255.0
```
## 固定wlan名称
sudo nano /etc/udev/rules.d/10-network.rules
``` bash
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="MAC_address",name="wlan0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="MAC_address",name="wlan1"
```
## 安装配饰DHCP服务
sudo apt install dnsmasq
nano /etc/dnsmasq.conf
``` bash
listen-address = 127.0.0.1, 192.168.1.1, 192.168.2.1
dhcp-range = 192.168.1.20, 192.168.1.200, 12h
dhcp-range = 192.168.1.20, 192.168.1.200, 12h
```
## 开启内核转发包服务
sudo nano /etc/sysctl.conf
``` bash
net ipv4.ip_forward = 1 #去掉注释
```

View File

@ -1,12 +1,32 @@
# 树莓派连接wifi # 树莓派连接wifi
# 命令行 ## 配置
/etc/network/interfaces
``` bash
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
#allow-hotplug wlan0
#iface wlan0 inet manual
iface wlan0 inet dhcp
wpa-conf /etc/wpa.conf
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
```
> sudo nano /etc/wpa_supplicant/wpa_supplicant.conf > sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
``` bash ``` bash
network={ network={
ssid="The_ESSID_from_earlier" ssid=""
psk="Your_wifi_password" key_mgmt=WPA-PSK
psk=""
} }
``` ```

View File

@ -0,0 +1 @@
iw list | grep -A 10 "Supported interface modes"