设置静态IP
打开/etc/network/interfaces 网络配置文件进行配置
sudo gedit /etc/network/interfaces
auto lo
iface lo inet loopback
interface eth0
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
或者可以修改/etc/dhcpcd.conf
(没试过到底可不可以)
# [必须]声明网卡: eth0(插网线) / wlan0(连接wifi)
# 可以通过 $ ifconfig 进行查看
interface wlan0
# [必须]静态IP地址:192.168.1.16;'/24'表示子网掩码为 255.255.255.0
static ip_address=192.168.1.16/24
# [可选]路由器/网关IP地址
static routers=192.168.1.1
# [可选]自定义DNS服务器
static domain_name_servers=192.168.1.1
依旧重启后生效
设置动态IP获取
依旧编辑网络配置文件,将设置固定IP的部分修改为自动获取IP
interface wlan0
iface wlan0 inet manual
interface eth0
iface eth0 inet manual