废话不多说直接讲

kakkk@kakkk:~$ cd /etc/netplan/
kakkk@kakkk:/etc/netplan$ ls    #查看配置文件的名字,修改它
00-installer-config.yaml
kakkk@kakkk:/etc/netplan$ sudo vim 00-installer-config.yaml

修改成你需要的配置

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: false                  # 改成false,关闭dhcp
      # 下面两个配置如果没有,手动输入
      addresses: [192.168.0.13/24]  # IP地址
      gateway4: 192.168.0.1         # 网关
  version: 2

保存(vim怎么保存自己想办法哈哈哈哈)

使新配置生效:

$ sudo netplan apply

查看结果:

kakkk@kakkk:/etc/netplan$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.13  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::20c:29ff:feef:6a63  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:ef:6a:63  txqueuelen 1000  (Ethernet)
        RX packets 206665  bytes 164082359 (164.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 108143  bytes 7112228 (7.1 MB)
        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
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 124  bytes 10708 (10.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 124  bytes 10708 (10.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

搞定,又水一文(只是记录啦,没有专门水的意思)

最后修改:2022 年 04 月 17 日
如果觉得我的文章对你有用,请随意赞赏