diff --git a/raspberry/router.md b/raspberry/router.md new file mode 100644 index 0000000..9da1594 --- /dev/null +++ b/raspberry/router.md @@ -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 #去掉注释 +``` \ No newline at end of file diff --git a/raspberry/wifi.md b/raspberry/wifi.md index 492152a..42a8b0c 100644 --- a/raspberry/wifi.md +++ b/raspberry/wifi.md @@ -1,12 +1,32 @@ # 树莓派连接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 ``` bash network={ - ssid="The_ESSID_from_earlier" - psk="Your_wifi_password" +    ssid="" +    key_mgmt=WPA-PSK +    psk="" } -``` \ No newline at end of file +``` + diff --git a/ubuntu/网络相关命令.md b/ubuntu/网络相关命令.md new file mode 100644 index 0000000..1ae5a62 --- /dev/null +++ b/ubuntu/网络相关命令.md @@ -0,0 +1 @@ +iw list | grep -A 10 "Supported interface modes"