配置网络
```
root@raspberrypi:~# sudo nano /etc/dhcpcd.conf
#配置网卡IP
interface eth0
static ip_address=192.168.1.218/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
#配置无线网卡静态IP
interface wlan0
static ip_address=192.168.1.118/24
static routers=192.168.1.1
static domain_name_servers=114.114.114.114
root@raspberrypi:~# sudo nano /etc/sysctl.conf
#禁用IPv6
net.ipv4.ip_forward=1
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
```
静态IP配置
```
#修改/etc/network/interfaces文件
iface eth0 inet static
address 192.168.1.88
netmask 255.255.255.0
gateway 192.168.1.1
#修改DNS
root@raspberrypi:~# sudo cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 208.67.220.220
nameserver 208.67.222.222
nameserver 10.10.10.10
```
查看网络信息
```
root@raspberrypi:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.218 netmask 255.255.255.0 broadcast 192.168.1.255
ether b8:27:eb:70:6e:7e txqueuelen 1000 (Ethernet)
RX packets 664 bytes 55451 (54.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 762 bytes 56915 (55.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 314 bytes 29830 (29.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 314 bytes 29830 (29.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:25:3b:2b txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
```
查找WIFI
```
root@raspberrypi:~# sudo iwlist wlan0 scan
root@raspberrypi:~# sudo iwlist scan | grep ESSID
eth0 Interface doesn't support scanning.
lo Interface doesn't support scanning.
ESSID:"TP-LINK_98C0"
ESSID:"404"
ESSID:"CMCC-qVYW"
ESSID:"ChinaNet-304-5G"
ESSID:"ChinaNet-304"
ESSID:"fcx"
ESSID:"Tenda_479220"
ESSID:"Honor 10"
ESSID:"@PHICOMM_BC"
```
配置无线网络
```
root@raspberrypi:~# sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=CN
network={
#你的无线网络ssid
ssid="xxxxxx"
#你wifi的密码
psk="xxxxxxxx"
key_mgmt=WPA-PSK
priority=1
}
root@raspberrypi:~# ifconfig wlan0
# 重启网络
root@raspberrypi:~# sudo /etc/init.d/networking restart
```
连接WiFi
```
root@raspberrypi:~# sudo ifup wlan0
root@raspberrypi:~# sudo ifdown wlan0
```