Ubuntu20.04用NetworkManager的 nmcli connection modify 连接的名称或UUID 来设置IPV4 笔记240619

用NetworkManager的 nmcli connection modify 连接的名称或UUID ipv4.address 来设置IPV4

用NetworkManager的 nmcli connection modify 连接的名称或UUID ipv4.address 来设置IP 的模板

只设置修改IP

覆盖原有设置: ipv4.addressesipv4.addripv4.a

NameOrUuidOfConnection="连接名或UUID"    ####  连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
ipv4.addresses "1.2.3.1/8 , 1.2.3.2/8, 1.2.3.3/8,1.2.3.4/8" ;
sudo nmcli connection down "${NameOrUuidOfConnection}"; sudo nmcli connection up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

只添加IP

在原有基础上添加:前面加加号 +ipv4.addresses+ipv4.addr+ipv4.a

NameOrUuidOfConnection="连接名或UUID"    ####  连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
+ipv4.addresses "1.2.3.1/8 , 1.2.3.2/8, 1.2.3.3/8,1.2.3.4/8" ;
sudo nmcli connection down "${NameOrUuidOfConnection}"; sudo nmcli connection up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

删除指定IP

在原有基础上添加:前面加减号 -ipv4.addresses-ipv4.addr-ipv4.a

NameOrUuidOfConnection="连接名或UUID"    ####  连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
-ipv4.addresses "1.2.3.1/8 , 1.2.3.2/8, 1.2.3.3/8,1.2.3.4/8" ;
sudo nmcli connection down "${NameOrUuidOfConnection}"; sudo nmcli connection up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

设置静态IP的模板1

NameOrUuidOfConnection="ba4afbc8-c846-3a49-b222-18ee39f8c6cc"    ####  连接名或UUID     连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
ipv4.method 'manual'    \
ipv4.addresses "1.20.46.30/8 , 1.20.46.31/8, 1.20.46.32/8 ,1.20.46.33/8,1.20.46.34/8,1.20.46.35/8  ,1.2.3.4,5.6.7.8,1.2.3.4/6,5.6.7.8/6 , 192.168.3.3 , 192.168.3.3/8 , 192.168.3.3/16 , 192.168.3.3/24 , 192.168.3.3/32  "    \
+ipv4.a         1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
-ipv4.addr      1.20.46.30/8,1.20.46.37/8,1.20.46.39/8,1.20.46.40/8,1.20.46.41,1.20.46.42/8    \
ipv4.gateway "1.0.0.2"    \
ipv4.ignore-auto-dns 'true'    \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5  1.1.1.1,8.8.8.8,114.114.114.114,114.114.115.115 , 4.2.2.1,4.2.2.2"    \
ipv4.dns-search 'baidu.com' ;    \
# sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ;    ####  重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli c down "${NameOrUuidOfConnection}"; sudo nmcli c up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

代码说明 , 不能直接粘贴使用, 反斜杠\之后必须换行, 空格都不能有
"${NameOrUuidOfConnection}"要加双引号,不加的话连接名称不能有空格

NameOrUuidOfConnection=“ba4afbc8-c846-3a49-b222-18ee39f8c6cc” ####
连接名或UUID 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show
查看 sudo nmcli connection modify “KaTeX parse error: Expected 'EOF', got '#' at position 35: …tion}" \ #̲## nmcli connec…{NameOrUuidOfConnection}”; sudo nmcli c up
“${NameOrUuidOfConnection}”; #### nmcli connection dowan 和 nmcli
connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

简化名称

命令简写

NameOrUuidOfConnection="ba4afbc8-c846-3a49-b222-18ee39f8c6cc"    ####  连接名或UUID     连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli c n "${NameOrUuidOfConnection}"    \
ipv4.me 'manual'    \
ipv4.a    "1.20.46.30/8 , 1.20.46.31/8, 1.20.46.32/8 ,1.20.46.33/8,1.20.46.34/8,1.20.46.35/8  ,1.2.3.4,5.6.7.8,1.2.3.4/6,5.6.7.8/6 , 192.168.3.3 , 192.168.3.3/8 , 192.168.3.3/16 , 192.168.3.3/24 , 192.168.3.3/32  "    \
+ipv4.a    1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
-ipv4.a    1.20.46.30/8,1.20.46.37/8,1.20.46.39/8,1.20.46.40/8,1.20.46.41,1.20.46.42/8    \
ipv4.gateway "1.0.0.2"    \
ipv4.ignore-auto-dns 'true'    \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5  1.1.1.1,8.8.8.8,114.114.114.114,114.114.115.115 , 4.2.2.1,4.2.2.2"    \
ipv4.dns-search 'baidu.com' ;    \
# sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ;    ####  重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli c d "${NameOrUuidOfConnection}"; sudo nmcli c u "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

简化内容

不要 +ipv4.addresses , -ipv4.addresses 和搜索域 +ipv4.dns-search

NameOrUuidOfConnection="连接的名称或UUID"    ####  连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
ipv4.method 'manual'    \
ipv4.addresses "1.2.3.1/8 , 1.2.3.2/8, 1.2.3.3/8,1.2.3.4/8"    \
ipv4.gateway "1.0.0.2"    \
ipv4.ignore-auto-dns 'true'    \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5  1.1.1.1,8.8.8.8,114.114.114.114 , 114.114.115.115 , 4.2.2.1,4.2.2.2"    \
# sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ;    ####  重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli connection down "${NameOrUuidOfConnection}"; sudo nmcli connection up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

简化名称和内容

NameOrUuidOfConnection="连接的名称或UUID"    ####  连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli c m "${NameOrUuidOfConnection}"    \
ipv4.me 'manual'    \
ipv4.a "1.2.3.1/8 , 1.2.3.2/8, 1.2.3.3/8,1.2.3.4/8"    \
ipv4.g "1.0.0.2"    \
ipv4.ignore-auto-d 'true'    \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5  1.1.1.1,8.8.8.8,114.114.114.114 , 114.114.115.115 , 4.2.2.1,4.2.2.2"    \
ipv4.dns-s 'baidu.com' ;    \
# sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ;    ####  重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli c d "${NameOrUuidOfConnection}"; sudo nmcli c u "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭




测试演示

测试演示1

在 Ubuntu20.04.06下测试

NameOrUuidOfConnection="ba4afbc8-c846-3a49-b222-18ee39f8c6cc"    ####  连接名或UUID     连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
ipv4.method 'manual'    \
ipv4.addresses "1.20.46.30/8 , 1.20.46.31/8, 1.20.46.32/8 ,1.20.46.33/8,1.20.46.34/8,1.20.46.35/8  ,1.2.3.4,5.6.7.8,1.2.3.4/6,5.6.7.8/6 , 192.168.3.3 , 192.168.3.3/8 , 192.168.3.3/16 , 192.168.3.3/24 , 192.168.3.3/32  "    \
+ipv4.a         1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
-ipv4.addr      1.20.46.30/8,1.20.46.37/8,1.20.46.39/8,1.20.46.40/8,1.20.46.41,1.20.46.42/8    \
ipv4.gateway "1.0.0.2"    \
ipv4.ignore-auto-dns 'true'    \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5  1.1.1.1,8.8.8.8,114.114.114.114 , 114.114.115.115"    \
ipv4.dns-search 'baidu.com' ;    \
# sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ;    ####  重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli c down "${NameOrUuidOfConnection}"; sudo nmcli c up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

代码说明 , 不能直接粘贴使用, 反斜杠\之后必须换行, 空格都不能有

NameOrUuidOfConnection=“ba4afbc8-c846-3a49-b222-18ee39f8c6cc” ####
连接名或UUID 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show
查看 sudo nmcli connection modify “KaTeX parse error: Expected 'EOF', got '#' at position 35: …tion}" \ #̲## nmcli connec…{NameOrUuidOfConnection}”; sudo nmcli c up
“${NameOrUuidOfConnection}”; #### nmcli connection dowan 和 nmcli
connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

上面的代码在 /etc/NetworkManager/system-connections 文件夹中生成了一个 以连接名开头的.nmconnection 文件

root@ud2046:/etc/NetworkManager/system-connections# ls
'Wired connection 3.nmconnection'

内容如下

[connection]
id=Wired connection 3
uuid=ba4afbc8-c846-3a49-b222-18ee39f8c6cc
type=ethernet
autoconnect-priority=-999
interface-name=ens38
permissions=
timestamp=1718738263[ethernet]
mac-address-blacklist=[ipv4]
address1=1.20.46.31/8,1.0.0.2
address2=1.20.46.32/8
address3=1.20.46.33/8
address4=1.20.46.34/8
address5=1.20.46.35/8
address6=1.2.3.4/32
address7=5.6.7.8/32
address8=1.2.3.4/6
address9=5.6.7.8/6
address10=192.168.3.3/32
address11=192.168.3.3/8
address12=192.168.3.3/16
address13=192.168.3.3/24
address14=1.20.46.36/8
address15=1.20.46.38/8
dns=180.76.76.76;223.6.6.6;119.29.29.29;223.5.5.5;1.1.1.1;8.8.8.8;114.114.114.114;114.114.115.115;
dns-search=baidu.com;
ignore-auto-dns=true
method=manual[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto[proxy]

执行 ip a|grep 'inet ' 的结果

root@ud2046:/home/z# ip a|grep 'inet 'inet 127.0.0.1/8 scope host loinet 1.128.0.4/8 brd 1.255.255.255 scope global dynamic noprefixroute ens33inet 1.128.0.21/8 brd 1.255.255.255 scope global dynamic noprefixroute ens37inet 1.20.46.31/8 brd 1.255.255.255 scope global noprefixroute ens38inet 1.2.3.4/32 scope global noprefixroute ens38inet 5.6.7.8/32 scope global noprefixroute ens38inet 1.2.3.4/6 brd 3.255.255.255 scope global noprefixroute ens38inet 5.6.7.8/6 brd 7.255.255.255 scope global noprefixroute ens38inet 192.168.3.3/32 scope global noprefixroute ens38inet 192.168.3.3/8 brd 192.255.255.255 scope global noprefixroute ens38inet 192.168.3.3/16 brd 192.168.255.255 scope global noprefixroute ens38inet 192.168.3.3/24 brd 192.168.3.255 scope global noprefixroute ens38inet 1.20.46.32/8 brd 1.255.255.255 scope global secondary noprefixroute ens38inet 1.20.46.33/8 brd 1.255.255.255 scope global secondary noprefixroute ens38inet 1.20.46.34/8 brd 1.255.255.255 scope global secondary noprefixroute ens38inet 1.20.46.35/8 brd 1.255.255.255 scope global secondary noprefixroute ens38inet 1.20.46.36/8 brd 1.255.255.255 scope global secondary noprefixroute ens38inet 1.20.46.38/8 brd 1.255.255.255 scope global secondary noprefixroute ens38

可看出

  • ip可设置多个, 不像Windows那样限制为1个
  • 不设置子网掩码的ip, 子网掩码为32, 1.2.3.4等效1.2.3.4/32
  • 相同ip不同子网掩码的条目被视为不同, 会分别添加
  • 相同ip相同子网掩码的条目被视为相同, 不会重复添加
  • 不存在的ip也可以写在 -ipv4.addresses 后面,不会报错,也没有影响. (24.04会出错,无法up连接)
  • 多个DNS的分隔,在nmcli c m命令中是逗号, 在 连接名.nmconnection文件中是分号
  • 执行后, 继续执行 sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ; 并没有生效, 生效的方法是
    • 重启系统
    • 或者注销重新登录
    • 或者在图形桌面右上角设置中关闭再打开对应的网络连接
    • 或者执行 nmcli connection down 连接名称或UUID 再执行 nmcli connection up 连接名称或UUID
      • nmcli connection down 可简写为 nmcli c d
      • nmcli connection up 可简写为 nmcli c u




测试演示2

还是在 Ubuntu20.04下测试

NameOrUuidOfConnection="Wired connection 3"    ####  连接名或UUID     连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
ipv4.method 'manual'    \
ipv4.addresses "1.20.46.30/8 , 1.20.46.31/8, 1.20.46.32/8 ,1.20.46.33/8,1.20.46.34/8,1.20.46.35/8  ,1.2.3.4,5.6.7.8,1.2.3.4/6,5.6.7.8/6 , 192.168.3.3 , 192.168.3.3/8 , 192.168.3.3/16 , 192.168.3.3/24 , 192.168.3.3/32  "    \
+ipv4.a         1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
+ipv4.addr         1.20.46.45/8,1.20.46.46/8,1.20.46.47/8,1.20.46.48/8,1.20.46.49/8,1.20.46.50/8    \
+ipv4.address         1.20.46.55/8,1.20.46.56/8,1.20.46.57/8,1.20.46.58/8,1.20.46.59/8,1.20.46.60/8    \
+ipv4.addresses         1.20.46.65/8,1.20.46.66/8,1.20.46.67/8,1.20.46.68/8,1.20.46.69/8,1.20.46.70/8    \
-ipv4.a      1.20.46.30/8,1.20.46.37/8,1.20.46.39/8,1.20.46.40/8,1.20.46.41,1.20.46.42/8    \
-ipv4.addr      1.20.46.45/8,1.20.46.46/8    \
-ipv4.address      1.20.46.47/8,1.20.46.48/8    \
-ipv4.addresses      1.20.46.49/8,1.20.46.50/8    \
ipv4.gateway "1.0.0.2"    \
ipv4.ignore-auto-dns 'true'    \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5  1.1.1.1,8.8.8.8,114.114.114.114,114.114.115.115 , 4.2.2.1,4.2.2.2"    \
ipv4.dns-search 'baidu.com' ;    \
# sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ;    ####  重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli c down "${NameOrUuidOfConnection}"; sudo nmcli c up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

/etc/NetworkManager/system-connections中生成的.nmconnection 文件内容如下

[connection]
id=Wired connection 3
uuid=ba4afbc8-c846-3a49-b222-18ee39f8c6cc
type=ethernet
autoconnect-priority=-999
interface-name=ens38
permissions=
timestamp=1718753140[ethernet]
mac-address-blacklist=[ipv4]
address1=1.20.46.31/8,1.0.0.2
address2=1.20.46.32/8
address3=1.20.46.33/8
address4=1.20.46.34/8
address5=1.20.46.35/8
address6=1.2.3.4/32
address7=5.6.7.8/32
address8=1.2.3.4/6
address9=5.6.7.8/6
address10=192.168.3.3/32
address11=192.168.3.3/8
address12=192.168.3.3/16
address13=192.168.3.3/24
address14=1.20.46.36/8
address15=1.20.46.38/8
address16=1.20.46.55/8
address17=1.20.46.56/8
address18=1.20.46.57/8
address19=1.20.46.58/8
address20=1.20.46.59/8
address21=1.20.46.60/8
address22=1.20.46.65/8
address23=1.20.46.66/8
address24=1.20.46.67/8
address25=1.20.46.68/8
address26=1.20.46.69/8
address27=1.20.46.70/8
dns=180.76.76.76;223.6.6.6;119.29.29.29;223.5.5.5;1.1.1.1;8.8.8.8;114.114.114.114;114.114.115.115;4.2.2.1;4.2.2.2;
dns-search=baidu.com;
ignore-auto-dns=true
method=manual[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto[proxy]

但同样的代码到 Ubuntu24.04中却执行不了了, 没法识别 ipv4.a , 因为新版本增加了以a开头的命令, 最短要用ipv4.ad

上面同样的代码在CentOS7中可以执行, 也可以用 ipv4.a , 但没有在 /etc/NetworkManager/system-connections中生成.nmconnection 文件 , 而是在/etc/sysconfig/network-scripts下生成了
ifcfg-有线连接_2 文件, 也可能是其它名称, 内容如下

HWADDR=00:0C:29:5E:80:51
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=1.20.46.31
PREFIX=8
IPADDR1=1.20.46.32
PREFIX1=8
IPADDR2=1.20.46.33
PREFIX2=8
IPADDR3=1.20.46.34
PREFIX3=8
IPADDR4=1.20.46.35
PREFIX4=8
IPADDR5=1.2.3.4
PREFIX5=32
IPADDR6=5.6.7.8
PREFIX6=32
IPADDR7=1.2.3.4
PREFIX7=6
IPADDR8=5.6.7.8
PREFIX8=6
IPADDR9=192.168.3.3
PREFIX9=32
IPADDR10=192.168.3.3
PREFIX10=8
IPADDR11=192.168.3.3
PREFIX11=16
IPADDR12=192.168.3.3
PREFIX12=24
IPADDR13=1.20.46.36
PREFIX13=8
IPADDR14=1.20.46.38
PREFIX14=8
IPADDR15=1.20.46.55
PREFIX15=8
IPADDR16=1.20.46.56
PREFIX16=8
IPADDR17=1.20.46.57
PREFIX17=8
IPADDR18=1.20.46.58
PREFIX18=8
IPADDR19=1.20.46.59
PREFIX19=8
IPADDR20=1.20.46.60
PREFIX20=8
IPADDR21=1.20.46.65
PREFIX21=8
IPADDR22=1.20.46.66
PREFIX22=8
IPADDR23=1.20.46.67
PREFIX23=8
IPADDR24=1.20.46.68
PREFIX24=8
IPADDR25=1.20.46.69
PREFIX25=8
IPADDR26=1.20.46.70
PREFIX26=8
GATEWAY=1.0.0.2
DNS1=180.76.76.76
DNS2=223.6.6.6
DNS3=119.29.29.29
DNS4=223.5.5.5
DNS5=1.1.1.1
DNS6=8.8.8.8
DNS7=114.114.114.114
DNS8=114.114.115.115
DNS9=4.2.2.1
DNS10=4.2.2.2
DOMAIN=baidu.com
DEFROUTE=yes
PEERDNS=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=$'\746\634\611\747\672\677\750\677\636\746\616\645 2'
UUID=c3f172fc-f403-3380-9c1d-94533d978c96
ONBOOT=yes
AUTOCONNECT_PRIORITY=-999

但同样的代码到 Ubuntu24.04中却执行不了了, 没法识别 ipv4.a , 因为新版本增加了以a开头的命令, 最短要用ipv4.ad ,改为 ipv4.ad后可以执行, 但没有在 /etc/NetworkManager/system-connections中生成.nmconnection 文件 , 而是在/etc/netplan下生成了90-NM-09d97ac1-b4e0-3111-a994-60b64f6f6b98.yaml 文件, 09d97ac1-b4e0-3111-a994-60b64f6f6b98对应连接的UUID, 内容如下

network:version: 2ethernets:ens35:renderer: NetworkManagermatch: {}addresses:- "1.20.46.31/8"- "1.20.46.32/8"- "1.20.46.33/8"- "1.20.46.34/8"- "1.20.46.35/8"- "1.2.3.4/32"- "5.6.7.8/32"- "1.2.3.4/6"- "5.6.7.8/6"- "192.168.3.3/32"- "192.168.3.3/8"- "192.168.3.3/16"- "192.168.3.3/24"- "1.20.46.36/8"- "1.20.46.38/8"- "1.20.46.55/8"- "1.20.46.56/8"- "1.20.46.57/8"- "1.20.46.58/8"- "1.20.46.59/8"- "1.20.46.60/8"- "1.20.46.65/8"- "1.20.46.66/8"- "1.20.46.67/8"- "1.20.46.68/8"- "1.20.46.69/8"- "1.20.46.70/8"nameservers:addresses:- 180.76.76.76- 223.6.6.6- 119.29.29.29- 223.5.5.5- 1.1.1.1- 8.8.8.8- 114.114.114.114- 114.114.115.115- 4.2.2.1- 4.2.2.2networkmanager:uuid: "09d97ac1-b4e0-3111-a994-60b64f6f6b98"name: "netplan-ens35"passthrough:connection.timestamp: "1718758772"ipv4.address1: "1.20.46.31/8,1.0.0.2"ipv4.dns-search: "baidu.com;"ipv4.ignore-auto-dns: "true"ipv4.method: "manual"proxy._: ""

nmcli c down 后,没法 nmcli c up 启动连接
原因是 不能用-inet4.addresses 去移除不存在的ip,

于是将脚本改成, 增加的和删除的一样,
另外, IP冲突也可能有莫名其妙的影响, 关掉多余系统, 更换IP

NameOrUuidOfConnection="netplan-ens35"    ####  连接名或UUID     连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
ipv4.method 'manual'    \
ipv4.addresses "1.24.4.30/8 , 1.24.4.31/8, 1.24.4.32/8 ,1.24.4.33/8,1.24.4.34/8,1.24.4.35/8  ,1.2.3.4,5.6.7.8,1.2.3.4/6,5.6.7.8/6 , 192.168.3.3 , 192.168.3.3/8 , 192.168.3.3/16 , 192.168.3.3/24 , 192.168.3.3/32  "    \
+ipv4.ad         1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
+ipv4.addr         1.20.46.45/8,1.20.46.46/8,1.20.46.47/8,1.20.46.48/8,1.20.46.49/8,1.20.46.50/8    \
+ipv4.address         1.20.46.55/8,1.20.46.56/8,1.20.46.57/8,1.20.46.58/8,1.20.46.59/8,1.20.46.60/8    \
+ipv4.addresses         1.20.46.65/8,1.20.46.66/8,1.20.46.67/8,1.20.46.68/8,1.20.46.69/8,1.20.46.70/8    \
-ipv4.ad         1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
-ipv4.addr         1.20.46.45/8,1.20.46.46/8,1.20.46.47/8,1.20.46.48/8,1.20.46.49/8,1.20.46.50/8    \
-ipv4.address         1.20.46.55/8,1.20.46.56/8,1.20.46.57/8,1.20.46.58/8,1.20.46.59/8,1.20.46.60/8    \
-ipv4.addresses         1.20.46.65/8,1.20.46.66/8,1.20.46.67/8,1.20.46.68/8,1.20.46.69/8,1.20.46.70/8    \
ipv4.gateway "1.0.0.2"    \
ipv4.ignore-auto-dns 'true'    \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5  1.1.1.1,8.8.8.8,114.114.114.114,114.114.115.115 , 4.2.2.1,4.2.2.2"    \
ipv4.dns-search 'baidu.com' ;    \
# sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ;    ####  重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli c down "${NameOrUuidOfConnection}"; sudo nmcli c up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

执行 netplan -get 命令到生成的yaml为

network:version: 2renderer: NetworkManagerethernets:ens33:dhcp4: trueens34:dhcp4: trueens35:renderer: NetworkManagermatch:name: "ens35"addresses:- "1.24.4.30/8"- "1.24.4.31/8"- "1.24.4.32/8"- "1.24.4.33/8"- "1.24.4.34/8"- "1.24.4.35/8"- "1.2.3.4/32"- "5.6.7.8/32"- "1.2.3.4/6"- "5.6.7.8/6"- "192.168.3.3/32"- "192.168.3.3/8"- "192.168.3.3/16"- "192.168.3.3/24"nameservers:addresses:- 180.76.76.76- 223.6.6.6- 119.29.29.29- 223.5.5.5- 1.1.1.1- 8.8.8.8- 114.114.114.114- 114.114.115.115- 4.2.2.1- 4.2.2.2dhcp4: truenetworkmanager:uuid: "09d97ac1-b4e0-3111-a994-60b64f6f6b98"name: "netplan-ens35"passthrough:connection.timestamp: "1718763322"ipv4.address1: "1.24.4.30/8,1.0.0.2"ipv4.dns-search: "baidu.com;"ipv4.ignore-auto-dns: "true"ipv4.method: "manual"proxy._: ""

更多IP尝试


NameOrUuidOfConnection="netplan-ens35"    ####  连接名或UUID     连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
ipv4.method 'manual'    \
ipv4.addresses "1.24.4.30/8 , 1.24.4.31/8, 1.24.4.32/8 ,1.24.4.33/8,1.24.4.34/8,1.24.4.35/8  ,  "    \
+ipv4.address "1.244.35.0/8,1.244.35.1/8,1.244.35.2/8,1.244.35.3/8,1.244.35.4/8,1.244.35.5/8,1.244.35.6/8,1.244.35.7/8,1.244.35.8/8,1.244.35.9/8,1.244.35.10/8,1.244.35.11/8,1.244.35.12/8,1.244.35.13/8,1.244.35.14/8,1.244.35.15/8,1.244.35.16/8,1.244.35.17/8,1.244.35.18/8,1.244.35.19/8,1.244.35.20/8,1.244.35.21/8,1.244.35.22/8,1.244.35.23/8,1.244.35.24/8,1.244.35.25/8,1.244.35.26/8,1.244.35.27/8,1.244.35.28/8,1.244.35.29/8,1.244.35.30/8,1.244.35.31/8,1.244.35.32/8,1.244.35.33/8,1.244.35.34/8,1.244.35.35/8,1.244.35.36/8,1.244.35.37/8,1.244.35.38/8,1.244.35.39/8,1.244.35.40/8,1.244.35.41/8,1.244.35.42/8,1.244.35.43/8,1.244.35.44/8,1.244.35.45/8,1.244.35.46/8,1.244.35.47/8,1.244.35.48/8,1.244.35.49/8,1.244.35.50/8,1.244.35.51/8,1.244.35.52/8,1.244.35.53/8,1.244.35.54/8,1.244.35.55/8,1.244.35.56/8,1.244.35.57/8,1.244.35.58/8,1.244.35.59/8,1.244.35.60/8,1.244.35.61/8,1.244.35.62/8,1.244.35.63/8,1.244.35.64/8,1.244.35.65/8,1.244.35.66/8,1.244.35.67/8,1.244.35.68/8,1.244.35.69/8,1.244.35.70/8,1.244.35.71/8,1.244.35.72/8,1.244.35.73/8,1.244.35.74/8,1.244.35.75/8,1.244.35.76/8,1.244.35.77/8,1.244.35.78/8,1.244.35.79/8,1.244.35.80/8,1.244.35.81/8,1.244.35.82/8,1.244.35.83/8,1.244.35.84/8,1.244.35.85/8,1.244.35.86/8,1.244.35.87/8,1.244.35.88/8,1.244.35.89/8,1.244.35.90/8,1.244.35.91/8,1.244.35.92/8,1.244.35.93/8,1.244.35.94/8,1.244.35.95/8,1.244.35.96/8,1.244.35.97/8,1.244.35.98/8,1.244.35.99/8, " \
+ipv4.ad         1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
+ipv4.addr         1.20.46.45/8,1.20.46.46/8,1.20.46.47/8,1.20.46.48/8,1.20.46.49/8,1.20.46.50/8    \
+ipv4.address         1.20.46.55/8,1.20.46.56/8,1.20.46.57/8,1.20.46.58/8,1.20.46.59/8,1.20.46.60/8    \
+ipv4.addresses         1.20.46.65/8,1.20.46.66/8,1.20.46.67/8,1.20.46.68/8,1.20.46.69/8,1.20.46.70/8    \
-ipv4.ad         1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
-ipv4.addr         1.20.46.45/8,1.20.46.46/8,1.20.46.47/8,1.20.46.48/8,1.20.46.49/8,1.20.46.50/8    \
-ipv4.address         1.20.46.55/8,1.20.46.56/8,1.20.46.57/8,1.20.46.58/8,1.20.46.59/8,1.20.46.60/8    \
-ipv4.addresses         1.20.46.65/8,1.20.46.66/8,1.20.46.67/8,1.20.46.68/8,1.20.46.69/8,1.20.46.70/8    \
ipv4.gateway "1.0.0.2"    \
ipv4.ignore-auto-dns 'true'    \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5  1.1.1.1,8.8.8.8,114.114.114.114,114.114.115.115 , 4.2.2.1,4.2.2.2"    \
ipv4.dns-search 'baidu.com' ;    \
# sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ;    ####  重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli c down "${NameOrUuidOfConnection}"; sudo nmcli c up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭

应用成功

NameOrUuidOfConnection="netplan-ens35"    ####  连接名或UUID     连接的名称或UUID可用 nmcli c 或 nmcli c s 或  nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}"    \
ipv4.method 'manual'    \
ipv4.addresses "1.24.4.30/8 , 1.24.4.31/8, 1.24.4.32/8 ,1.24.4.33/8,1.24.4.34/8,1.24.4.35/8  ,  "    \
+ipv4.address "1.244.35.0/8,1.244.35.1/8,1.244.35.2/8,1.244.35.3/8,1.244.35.4/8,1.244.35.5/8,1.244.35.6/8,1.244.35.7/8,1.244.35.8/8,1.244.35.9/8,1.244.35.10/8,1.244.35.11/8,1.244.35.12/8,1.244.35.13/8,1.244.35.14/8,1.244.35.15/8,1.244.35.16/8,1.244.35.17/8,1.244.35.18/8,1.244.35.19/8,1.244.35.20/8,1.244.35.21/8,1.244.35.22/8,1.244.35.23/8,1.244.35.24/8,1.244.35.25/8,1.244.35.26/8,1.244.35.27/8,1.244.35.28/8,1.244.35.29/8,1.244.35.30/8,1.244.35.31/8,1.244.35.32/8,1.244.35.33/8,1.244.35.34/8,1.244.35.35/8,1.244.35.36/8,1.244.35.37/8,1.244.35.38/8,1.244.35.39/8,1.244.35.40/8,1.244.35.41/8,1.244.35.42/8,1.244.35.43/8,1.244.35.44/8,1.244.35.45/8,1.244.35.46/8,1.244.35.47/8,1.244.35.48/8,1.244.35.49/8,1.244.35.50/8,1.244.35.51/8,1.244.35.52/8,1.244.35.53/8,1.244.35.54/8,1.244.35.55/8,1.244.35.56/8,1.244.35.57/8,1.244.35.58/8,1.244.35.59/8,1.244.35.60/8,1.244.35.61/8,1.244.35.62/8,1.244.35.63/8,1.244.35.64/8,1.244.35.65/8,1.244.35.66/8,1.244.35.67/8,1.244.35.68/8,1.244.35.69/8,1.244.35.70/8,1.244.35.71/8,1.244.35.72/8,1.244.35.73/8,1.244.35.74/8,1.244.35.75/8,1.244.35.76/8,1.244.35.77/8,1.244.35.78/8,1.244.35.79/8,1.244.35.80/8,1.244.35.81/8,1.244.35.82/8,1.244.35.83/8,1.244.35.84/8,1.244.35.85/8,1.244.35.86/8,1.244.35.87/8,1.244.35.88/8,1.244.35.89/8,1.244.35.90/8,1.244.35.91/8,1.244.35.92/8,1.244.35.93/8,1.244.35.94/8,1.244.35.95/8,1.244.35.96/8,1.244.35.97/8,1.244.35.98/8,1.244.35.99/8, " \
+ipv4.ad         1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
+ipv4.addr         1.20.46.45/8,1.20.46.46/8,1.20.46.47/8,1.20.46.48/8,1.20.46.49/8,1.20.46.50/8    \
+ipv4.address         1.20.46.55/8,1.20.46.56/8,1.20.46.57/8,1.20.46.58/8,1.20.46.59/8,1.20.46.60/8    \
+ipv4.addresses         1.20.46.65/8,1.20.46.66/8,1.20.46.67/8,1.20.46.68/8,1.20.46.69/8,1.20.46.70/8    \
-ipv4.ad         1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8    \
-ipv4.addr         1.20.46.45/8,1.20.46.46/8,1.20.46.47/8,1.20.46.48/8,1.20.46.49/8,1.20.46.50/8    \
-ipv4.address         1.20.46.55/8,1.20.46.56/8,1.20.46.57/8,1.20.46.58/8,1.20.46.59/8,1.20.46.60/8    \
-ipv4.addresses         1.20.46.65/8,1.20.46.66/8,1.20.46.67/8,1.20.46.68/8,1.20.46.69/8,1.20.46.70/8    \
ipv4.gateway "1.0.0.2"    \
ipv4.ignore-auto-dns 'true'    \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5  1.1.1.1,8.8.8.8,114.114.114.114,114.114.115.115 , 4.2.2.1,4.2.2.2"    \
ipv4.dns-search 'baidu.com' ;    \
# sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ;    ####  重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli c down "${NameOrUuidOfConnection}"; sudo nmcli c up "${NameOrUuidOfConnection}";    #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭
Connection 'netplan-ens35' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
root@z-VMware20-1:~# ip a|grep 'inet 'inet 127.0.0.1/8 scope host loinet 1.244.33.0/8 brd 1.255.255.255 scope global noprefixroute ens33inet 1.244.33.1/8 brd 1.255.255.255 scope global secondary noprefixroute ens33inet 1.244.33.2/8 brd 1.255.255.255 scope global secondary noprefixroute ens33inet 1.244.33.3/8 brd 1.255.255.255 scope global secondary noprefixroute ens33inet 1.244.33.4/8 brd 1.255.255.255 scope global secondary noprefixroute ens33inet 1.244.33.5/8 brd 1.255.255.255 scope global secondary noprefixroute ens33inet 1.244.33.6/8 brd 1.255.255.255 scope global secondary noprefixroute ens33inet 1.244.33.7/8 brd 1.255.255.255 scope global secondary noprefixroute ens33inet 1.244.33.8/8 brd 1.255.255.255 scope global secondary noprefixroute ens33inet 1.244.33.9/8 brd 1.255.255.255 scope global secondary noprefixroute ens33inet 1.128.0.24/8 brd 1.255.255.255 scope global dynamic noprefixroute ens34inet 1.24.4.30/8 brd 1.255.255.255 scope global noprefixroute ens35inet 1.24.4.31/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.24.4.32/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.24.4.33/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.24.4.34/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.24.4.35/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.0/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.1/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.2/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.3/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.4/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.5/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.6/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.7/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.8/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.9/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.10/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.11/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.12/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.13/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.14/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.15/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.16/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.17/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.18/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.19/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.20/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.21/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.22/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.23/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.24/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.25/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.26/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.27/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.28/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.29/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.30/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.31/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.32/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.33/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.34/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.35/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.36/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.37/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.38/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.39/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.40/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.41/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.42/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.43/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.44/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.45/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.46/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.47/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.48/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.49/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.50/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.51/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.52/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.53/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.54/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.55/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.56/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.57/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.58/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.59/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.60/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.61/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.62/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.63/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.64/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.65/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.66/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.67/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.68/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.69/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.70/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.71/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.72/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.73/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.74/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.75/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.76/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.77/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.78/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.79/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.80/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.81/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.82/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.83/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.84/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.85/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.86/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.87/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.88/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.89/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.90/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.91/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.92/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.93/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.94/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.95/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.96/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.97/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.98/8 brd 1.255.255.255 scope global secondary noprefixroute ens35inet 1.244.35.99/8 brd 1.255.255.255 scope global secondary noprefixroute ens35

netplan get 查看生成的yaml

network:version: 2renderer: NetworkManagerethernets:ens33:renderer: NetworkManagermatch:name: "ens33"addresses:- "1.244.33.0/8"- "1.244.33.1/8"- "1.244.33.2/8"- "1.244.33.3/8"- "1.244.33.4/8"- "1.244.33.5/8"- "1.244.33.6/8"- "1.244.33.7/8"- "1.244.33.8/8"- "1.244.33.9/8"nameservers:addresses:- 180.76.76.76- 223.6.6.6- 119.29.29.29- 223.5.5.5- 1.1.1.1- 8.8.8.8- 114.114.114.114- 114.114.115.115- 4.2.2.1- 4.2.2.2dhcp4: truenetworkmanager:uuid: "14f59568-5076-387a-aef6-10adfcca2e26"name: "netplan-ens33"passthrough:connection.timestamp: "1718762948"ipv4.address1: "1.244.33.0/8,1.0.0.2"ipv4.dns-search: "baidu.com;"ipv4.ignore-auto-dns: "true"ipv4.method: "manual"proxy._: ""ens34:dhcp4: trueens35:renderer: NetworkManagermatch:name: "ens35"addresses:- "1.24.4.30/8"- "1.24.4.31/8"- "1.24.4.32/8"- "1.24.4.33/8"- "1.24.4.34/8"- "1.24.4.35/8"- "1.244.35.0/8"- "1.244.35.1/8"- "1.244.35.2/8"- "1.244.35.3/8"- "1.244.35.4/8"- "1.244.35.5/8"- "1.244.35.6/8"- "1.244.35.7/8"- "1.244.35.8/8"- "1.244.35.9/8"- "1.244.35.10/8"- "1.244.35.11/8"- "1.244.35.12/8"- "1.244.35.13/8"- "1.244.35.14/8"- "1.244.35.15/8"- "1.244.35.16/8"- "1.244.35.17/8"- "1.244.35.18/8"- "1.244.35.19/8"- "1.244.35.20/8"- "1.244.35.21/8"- "1.244.35.22/8"- "1.244.35.23/8"- "1.244.35.24/8"- "1.244.35.25/8"- "1.244.35.26/8"- "1.244.35.27/8"- "1.244.35.28/8"- "1.244.35.29/8"- "1.244.35.30/8"- "1.244.35.31/8"- "1.244.35.32/8"- "1.244.35.33/8"- "1.244.35.34/8"- "1.244.35.35/8"- "1.244.35.36/8"- "1.244.35.37/8"- "1.244.35.38/8"- "1.244.35.39/8"- "1.244.35.40/8"- "1.244.35.41/8"- "1.244.35.42/8"- "1.244.35.43/8"- "1.244.35.44/8"- "1.244.35.45/8"- "1.244.35.46/8"- "1.244.35.47/8"- "1.244.35.48/8"- "1.244.35.49/8"- "1.244.35.50/8"- "1.244.35.51/8"- "1.244.35.52/8"- "1.244.35.53/8"- "1.244.35.54/8"- "1.244.35.55/8"- "1.244.35.56/8"- "1.244.35.57/8"- "1.244.35.58/8"- "1.244.35.59/8"- "1.244.35.60/8"- "1.244.35.61/8"- "1.244.35.62/8"- "1.244.35.63/8"- "1.244.35.64/8"- "1.244.35.65/8"- "1.244.35.66/8"- "1.244.35.67/8"- "1.244.35.68/8"- "1.244.35.69/8"- "1.244.35.70/8"- "1.244.35.71/8"- "1.244.35.72/8"- "1.244.35.73/8"- "1.244.35.74/8"- "1.244.35.75/8"- "1.244.35.76/8"- "1.244.35.77/8"- "1.244.35.78/8"- "1.244.35.79/8"- "1.244.35.80/8"- "1.244.35.81/8"- "1.244.35.82/8"- "1.244.35.83/8"- "1.244.35.84/8"- "1.244.35.85/8"- "1.244.35.86/8"- "1.244.35.87/8"- "1.244.35.88/8"- "1.244.35.89/8"- "1.244.35.90/8"- "1.244.35.91/8"- "1.244.35.92/8"- "1.244.35.93/8"- "1.244.35.94/8"- "1.244.35.95/8"- "1.244.35.96/8"- "1.244.35.97/8"- "1.244.35.98/8"- "1.244.35.99/8"nameservers:addresses:- 180.76.76.76- 223.6.6.6- 119.29.29.29- 223.5.5.5- 1.1.1.1- 8.8.8.8- 114.114.114.114- 114.114.115.115- 4.2.2.1- 4.2.2.2dhcp4: truenetworkmanager:uuid: "09d97ac1-b4e0-3111-a994-60b64f6f6b98"name: "netplan-ens35"passthrough:connection.timestamp: "1718766061"ipv4.address1: "1.24.4.30/8,1.0.0.2"ipv4.dns-search: "baidu.com;"ipv4.ignore-auto-dns: "true"ipv4.method: "manual"proxy._: ""







命令简写

  • con 可以写成 cconnection 之间的字段
  • mod 可以写成 mmodify 之间的字段
    nmcli connection modify
    nmcli connect modify
    nmcli connec modify
    nmcli conne modif
    nmcii conn modi
    nmcli con mod
    nmcli co mo
    nmcli c m
    nmcli c modify
    nmcli connection m
    nmcli connect modify
    nmcli connection modify
    
  • ipv4. 可以接 [method, dns, dns-search, dns-options, dns-priority, addresses, gateway, routes, route-metric, route-table, routing-rules, ignore-auto-routes, ignore-auto-dns, dhcp-client-id, dhcp-iaid, dhcp-timeout, dhcp-send-hostname, dhcp-hostname, dhcp-fqdn, dhcp-hostname-flags, never-default, may-fail, required-timeout, dad-timeout, dhcp-vendor-class-identifier, dhcp-reject-servers] 。
    • ipv4.method最简可写成ipv4.me
    • ipv4.addresses 在Ubuntu20.04中最简可写成 ipv4.a, 在24.04中却不能,因为新版本添加了a开头的命令
    • ipv4.gateway能简写为ipv4.g(ipv4.gateway)只能有一个, (在图形界面也只能设置一个), 如果没设置网关就不能上网,但只要有ip地址,就能让网段内其它主机访问,比如ssh连接,没有网关就是能进不能出
    • ipv4.dns不能简写,可一次设置多个, +ipv4.dns可多次设置多个
    • ipv4.dns-search可简写为ipv4.dns-s , 搜索域
    • ipv4.ignore-auto-dns 取值 true|fasle , 最简只能写成ipv4.ignore-auto-d

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/30032.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

leetcode 二分查找·系统掌握 统计有序矩阵中的负数

题目: 给你一个 m * n 的矩阵 grid,矩阵中的元素无论是按行还是按列,都以非严格递减顺序排列。 请你统计并返回 grid 中 负数 的数目。 题解: 一种可行的解题思路是找出每一行中负数的个数再相加,又因为每一行单调递…

虚拟存储(Linux挂载点合并)

简介 在 Linux 中你有 3 块硬盘(或分区)分别为 100G、200G 和 300 G,如何在一个统一的路径下访问 600G 的视频文件夹呢?并且任何一个磁盘数据的损坏是不能影响其他两个磁盘中的数据,也不影响其他磁盘的正常访问。 相信大多数用户会想到几种解决办法: 买个更大的硬盘 ̄□ ̄…

Git 克隆 GitHub 仓库时遇到了 SSL 证书问题

fatal: unable to access GitHub - xxxxxxxxxxx: SSL certificate problem: unable to get local issuer certificate 使用 HTTP 代替 HTTPS: 如果 SSL 证书问题无法解决,您可以尝试使用 HTTP 克隆仓库(不推荐,因为不安全)。但请注…

Android device/xxx/system/common/overlay编译产物

MTK 如下代码编译的产物在 framework-res.apk 编译配置文件在device/mediatek/system/common/目录下的Android.bp device/mediatek/system/common/overlay/telephony/frameworks/base/core/res/res/values-mcc655-mnc01/config.xml 在Android U上面还在overlay目录中进行了产…

图像的高频和低频细节

在图像处理和计算机视觉中,"高频"和"低频"是用来描述图像中不同类型细节的术语。这些术语源自信号处理领域,其中频率的概念用于描述信号随时间变化的,但在图像处理中,它们被用来描述图像随空间变化的&#xf…

python是TIOBE编程语言排名第一的编程语言,它有什么优点?它的使用场景有哪些?用python打印数字1--100,用python打印九九乘法表怎么写?

Python是TIOBE编程语言排行榜排名第一的编程语言 。 python是一种解释性、交互式、面向对象的跨平台的语言。 python设计者及名称由来 Guido van Rossum 荷兰人---吉多范罗苏姆,是 Python 编程语言的最初设计者,在 Python 社区一直担当终身仁慈独裁者&…

教你如何安装 IntelliJ IDEA

安装 IntelliJ IDEA 的步骤通常如下,这里提供的是基于 Windows 系统的安装指南。 下载 IntelliJ IDEA 1. 访问 JetBrains 官方网站:[https://www.jetbrains.com/idea/download/](Download IntelliJ IDEA – The Leading Java and Kotlin IDE) 2. 选择适…

vue+echarts实现tooltip轮播

效果图如下: 实现步骤如下: 定义一个定时器 timer:null, len: 0,页面一加载就清空定时器,此操作是为了防止重复加载时会设置多个定时器在setOption后设置定时器 this.myChart.clear() this.myChart.setOption(option); this.autoShowTool…

java 面试题--基础

文章目录 基础java SE 、 EE 、 ME 的区别jdk 和 jre 区别?java 的日志级别基本数据类型 特性关键字finalabstractsuperswitchfortry catch 接口和抽象类的区别接口抽象类适用场景 类的加载循序静态代码块 传参问题访问修饰符运算符 反射java 里的应用为什么反射的性…

禹晶、肖创柏、廖庆敏《数字图像处理(面向新工科的电工电子信息基础课程系列教材)》Chapter 10插图

禹晶、肖创柏、廖庆敏《数字图像处理(面向新工科的电工电子信息基础课程系列教材)》 Chapter 10插图

YOLOv8旋转目标检测Yolov8n-obb详细实例+rolabelimg

一、Yolov8环境搭建 首先创建虚拟环境下载安装(其实就是yolov8的环境)再大概写一下步骤,没有想详细的看本人另外一篇:YOLOv8环境搭建_yolov8环境配置-CSDN博客 1、下载安装anaconda 2、创建虚拟环境 conda create -n my_yolov8…

二分查找算法模板

在算法题中&#xff0c;二分查找是一个很基础的能力&#xff0c;但是很多情况下都有可能因为一些小条件导致整题的错误&#xff0c;所以我们需要学习并记忆正确的写法&#xff0c;本篇列出了三种情况下的写法 闭区间写法 int lower_bound(vector<int> &nums, int ta…

【Gradio】Chatbot | 如何使用 Gradio Blocks 创建自定义聊天机器人

简介 重要提示&#xff1a;如果您刚开始接触&#xff0c;我们建议使用 gr.ChatInterface 来创建聊天机器人——它是一个高级抽象&#xff0c;使得可以快速创建漂亮的聊天机器人应用程序&#xff0c;往往只需一行代码。在这里了解更多信息。 本教程将展示如何使用 Gradio 的低级…

vue3中实现3D地图——three.js

需求点 地图区域大小随着父盒子大小变动&#xff0c;窗口缩放自动适配每个区域显示不同颜色和高度&#xff0c;描边每个区域显示名字label和icon点击区域改变其透明度&#xff0c;并且弹窗显示信息窗口点击点也可以可以自由放大缩小&#xff0c;360度旋转 包 npm install d3^…

单链表的插入及销毁

分数 5 作者 李卫明 单位 杭州电子科技大学 1.1编写程序&#xff0c;建立2个带头结点单链表&#xff0c;输入若干整数将正整数插入第1个单链表&#xff0c;将负整数插入第2个单链表&#xff0c;插入前和插入后单链表保持递增或相等次序&#xff0c;显示2个单链表&#xff0c…

背景渐变动画登录页

b站视频演示效果: 效果图: 完整代码: <!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>背景…

Python基础-函数

Python函数 函数是组织好的&#xff0c;可重复使用的&#xff0c;用来实现单一&#xff0c;或相关联功能的代码段。 函数能提高应用的模块性&#xff0c;和代码的重复利用率。你已经知道Python提供了许多内建函数&#xff0c;比如print()。但你也可以自己创建函数&#xff0c…

大模型商业化:李开复向左,张亚勤向右

文&#xff5c;白 鸽 “零一万物坚决做To C&#xff0c;不做赔钱的To B&#xff0c;要做能赚钱的To B。”2024年6月14日&#xff0c;在智源大会上&#xff0c;零一万物创始人李开复如此坚定地说道。 而与之相对&#xff0c;中国工程院院士、清华大学智能产业研究院&…

@property 详解

定义 python装饰器接受一个可调用对象作为输入&#xff0c;并返回一个新的可调用对象 比较 函数装饰器类装饰器方法装饰器参数接受函数作为参数接受类作为参数接受方法&#xff08;类的函数成员&#xff09;作为参数返回值返回一个新函数返回一个新类&#xff08;通常是原始…

掌握PostgreSQL:从安装到高级查询的全面教程

感谢您阅读本文&#xff0c;欢迎“一键三连”。作者定会不负众望&#xff0c;按时按量创作出更优质的内容。 ❤️ 1. 毕业设计专栏&#xff0c;毕业季咱们不慌&#xff0c;上千款毕业设计等你来选。 PostgreSQL是一种功能强大、开源的关系型数据库管理系统&#xff0c;广泛应用…