Ubuntu 從 17.10 開始,已放棄在
/etc/network/interfaces里固定IP的配置,而是改成 netplan 方式,Ubuntu 20.04.3配置文件是/etc/netplan/00-installer-config.yaml
配置文件
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
addresses:
- 10.0.0.4/24
gateway4: 10.0.0.1
nameservers:
addresses: [114.114.114.114]
search: []
version: 2
配置完成后,使用 netplan apply 讓其配置生效
ifconfig 配置臨時 IP 和掩碼
# 配置 IP 地址和掩碼
$ ifconfig eth0 10.0.0.2 netmask 255.255.255.0
#設置網關
$ route add default gw 10.0.0.1
