nmcli配置路由,链路和ipv6实例

nmcli 是NetworkManager的管理工具,使得网络配置更加简单

nmcli配置链路:

此链路在 desktopX 使用下面的地址 172.16.3.20/255.255.255.0
此链路在 serverX 使用下面的地址 172.16.3.25/255.255.255.0

desktop:

[root@desktop0 ~]# nmcli device status all
Unknown parameter: all
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected System eth0
eth1 ethernet connected --
eth2 ethernet connected --
lo loopback unmanaged --
[root@desktop0 ~]# nmcli connection add type team con-name team0
ifname team config '{"runner":{"name":"activebackup"}}'
Connection 'team0' (3d546c7c-2157-4853-847d-f1825d222f22) successfully
added.
[root@desktop0 ~]# nmcli connection show
NAME UUID TYPE DEVICE
team0 3d546c7c-2157-4853-847d-f1825d222f22 team team
System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
[root@desktop0 ~]# nmcli connection modify team0 ipv4.addresses
172.16.3.25/24 ipv4.method manual connection.autoconnect on
[root@desktop0 ~]# nmcli connection add type team-slave con-name
team0-p1 ifname eth1 master team
Connection 'team0-p1' (94209e43-dc67-44f3-9d20-df1339b611f4) successfully
added.
[root@desktop0 ~]# nmcli connection add type team-slave con-name
team0-p2 ifname eth2 master team
Connection 'team0-p2' (643a9395-8027-4e62-8079-279dd9e349cb) successfully
added.
[root@desktop0 ~]# nmcli connection up team0
Connection successfully activated (D-Bus active path:

/org/freedesktop/NetworkManager/ActiveConnection/4)


server:
[root@server0 ~]# nmcli device status all
Unknown parameter: all
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected System eth0
eth1 ethernet connected --
eth2 ethernet connected --
lo loopback unmanaged --
[root@server0 ~]# nmcli connection add type team con-name team0
ifname team config '{"runner":{"name":"activebackup"}}'
Connection 'team0' (3d546c7c-2157-4853-847d-f1825d222f22) successfully
added.
[root@server0 ~]# nmcli connection show
NAME UUID TYPE DEVICE
team0 3d546c7c-2157-4853-847d-f1825d222f22 team team
System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
[root@server0 ~]# nmcli connection modify team0 ipv4.addresses
172.16.3.25/24 ipv4.method manual connection.autoconnect on
[root@server0 ~]# nmcli connection add type team-slave con-name
team0-p1 ifname eth1 master team
Connection 'team0-p1' (94209e43-dc67-44f3-9d20-df1339b611f4) successfully
added.
[root@server0 ~]# nmcli connection add type team-slave con-name
team0-p2 ifname eth2 master team
Connection 'team0-p2' (643a9395-8027-4e62-8079-279dd9e349cb) successfully
added.
[root@server0 ~]# nmcli connection up team0
Connection successfully activated (D-Bus active path:

/org/freedesktop/NetworkManager/ActiveConnection/4)

nmcli 配置ipv6:

1. desktopX 上的地址应该是 2003:acl8::305/64
2. serverX 上的地址应该是 2003:acl8::30a/64

[root@desktop0 ~]# nmcli connection modify "System eth0"

ipv6.addresses 2003:ac18::305/64 ipv6.method manual

connection.autoconnect on
[root@desktop0 ~]# nmcli connection up "System eth0"
Connection successfully activated (D-Bus active path:

/org/freedesktop/NetworkManager/ActiveConnection/1)


[root@server0 ~]# nmcli connection modify "System eth0"
ipv6.addresses 2003:ac18::30a/64 ipv6.method manual
connection.autoconnect on
[root@server0 ~]# nmcli connection up "System eth0"
Connection successfully activated (D-Bus active path:

/org/freedesktop/NetworkManager/ActiveConnection/7)

nmcli 配置ipv4:

配置IPv4 网络
nmcli connection modify "System eth0" ipv4.addresses
"172.25.0.10/24 172.25.0.254" ipv4.dns 172.25.254.254
ipv4.method manual connection.autoconnect on
nmcli connection up "System eth0"

你可能感兴趣的:(Linux网络)