Ubuntu 20.04 LTS系统中修改IP地址,将DHCP自动分配的IP地址192.168.1.66改为静态IP地址192.168.1.75。
查看IP地址ens18: flags=4163查看netplan配置文件mtu 1500 inet 192.168.1.66 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::4029:99ff:febe:719f prefixlen 64 scopeid 0x20 ether 42:29:99:be:71:9f txqueuelen 1000 (Ethernet) RX packets 2494 bytes 306105 (306.1 KB) RX errors 0 dropped 22 overruns 0 frame 0 TX packets 384 bytes 51282 (51.2 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ sudo cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens18:
dhcp4: true
version: 2
默认配置是采用DHCP自动获取动态IP。
备份netplan配置文件sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config_backup.yaml修改netplan配置文件
$ sudo vim /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens18:
dhcp4: no
addresses: [192.168.1.75/24,]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 127.0.0.53]
version: 2
更多netplan命令参考官方网站。
检测netplan配置$ sudo netplan try Warning: Stopping systemd-networkd.service, but it can still be activated by: systemd-networkd.socket Do you want to keep these settings? Press ENTER before the timeout to accept the new configuration Changes will revert in 117 seconds Configuration accepted.
-
netplan try:应用配置并等待用户确认;如果网络损坏或未给出确认,将回滚。
-
netplan apply:应用渲染器的所有配置,必要时重新启动它们。
ens18: flags=4163mtu 1500 inet 192.168.1.75 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::4029:99ff:febe:719f prefixlen 64 scopeid 0x20 ether 42:29:99:be:71:9f txqueuelen 1000 (Ethernet) RX packets 61995 bytes 4987543 (4.9 MB) RX errors 0 dropped 22 overruns 0 frame 0 TX packets 3769 bytes 2592311 (2.5 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0



