mynote/raspberry/router.md
2018-01-03 17:10:42 +08:00

53 lines
940 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 用树莓派做路由器
## 网络配置
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 #去掉注释
```