Mint21配置固定IP不生效

rambo@p360:~$ ip a sh enp6s0
2: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether c8:5b:76:82:24:c0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.104/24 brd 192.168.2.255 scope global dynamic noprefixroute enp6s0
       valid_lft 7198sec preferred_lft 7198sec
    inet6 fe80::78a2:1042:4b7f:d45/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever



rambo@p360:~$ sudo vim /etc/netplan/1-network-manager-all.yaml
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enxf8e43b896488:
      dhcp4: no
      dhcp6: no
      addresses: [172.25.0.106/24]
    enp6s0:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.2.105/24]              # 从104改成105
      optional: true
      routes:
        - to: default
          via: 192.168.2.1
      nameservers:
        addresses: [8.8.8.8,8.8.4.4,223.5.5.5,114.114.114.110]



rambo@p360:~$ sudo chmod 600 /etc/netplan/1-network-manager-all.yaml
rambo@p360:~$ sudo netplan apply
rambo@p360:~$ nmcli con sh
NAME                     UUID                                  TYPE      DEVICE 
enp6s0                   4225c7fe-04bb-38cd-8136-1fe4d0cbc683  ethernet  enp6s0 

rambo@p360:~$ ip a sh enp6s0
2: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether c8:5b:76:82:24:c0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.104/24 brd 192.168.2.255 scope global dynamic noprefixroute enp6s0
       valid_lft 7165sec preferred_lft 7165sec
    inet6 fe80::78a2:1042:4b7f:d45/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

问题:还是192.168.2.104/24,没修改成功?




# 清除旧的DHCP租约
rambo@p360:~$ sudo dhclient -r enp6s0
rambo@p360:~$ sudo dhclient -v enp6s0

# 重启NetworkManager
rambo@p360:~$ sudo systemctl restart NetworkManager


rambo@p360:~$ sudo reboot

posted @ 2024-08-30 21:19  Linux大魔王  阅读(13)  评论(0编辑  收藏  举报