1.查看网络信息
[root@dsrw ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens160 04fe9326-bf57-44b8-9ef3-54f0db2498c3 ethernet ens160
virbr0 4201ee3a-2bf4-440c-8939-11c49e699ddd bridge virbr0
2.查看网卡信息
[root@dsrw ~]# nmcli connection show ens160
connection.id: ens160
connection.uuid: 04fe9326-bf57-44b8-9ef3-54f0db2498c3
connection.stable-id: --
connection.type: 802-3-ethernet
connection.interface-name: ens160
connection.autoconnect: 是
......
3.创建网络会话company(参数手动指定网络的IP、网关参数)
[root@dsrw ~]# nmcli connection add con-name company ifname ens160 autoconnect no type ethernet ip4 192.168.10.2/24 gw4 192.168.10.1
连接 "company" (0b0c2b9e-5e1f-4060-acab-e699a3cdfc74) 已成功添加。
4.创建网络会话 school(从外部DHCP服务器获得网络的IP、网关参数)
[root@dsrw ~]# nmcli connection add con-name school type ethernet ifname ens160
连接 "school" (130da14d-5922-4f3a-8971-8adc2cff6fd6) 已成功添加。
5.使用nmcli命令查看创建的所有网络会话
[root@dsrw ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens160 04fe9326-bf57-44b8-9ef3-54f0db2498c3 ethernet ens160
virbr0 4201ee3a-2bf4-440c-8939-11c49e699ddd bridge virbr0
company 0b0c2b9e-5e1f-4060-acab-e699a3cdfc74 ethernet --
School 130da14d-5922-4f3a-8971-8adc2cff6fd6 ethernet --
6.在company期间,启动company网络会话
[root@dsrw ~]# nmcli connection up company
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/5)
[root@dsrw ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.2 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::8782:14ae:73c2:4971 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:65:c4:9c txqueuelen 1000 (Ethernet)
RX packets 4475 bytes 1399221 (1.3 MiB)
RX errors 0 dropped 2872 overruns 0 frame 0
TX packets 1730 bytes 224792 (219.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
7.在school期间,启动school网络会话
[root@dsrw ~]# nmcli connection up school
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)
[root@dsrw ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.8 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::6ad9:d9b1:ca37:6a40 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:65:c4:9c txqueuelen 1000 (Ethernet)
RX packets 3321 bytes 1312010 (1.2 MiB)
RX errors 0 dropped 1821 overruns 0 frame 0
TX packets 1532 bytes 194262 (189.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
8.删除网络会话
[root@dsrw ~]# nmcli connection delete company
成功删除连接 "company" (0b0c2b9e-5e1f-4060-acab-e699a3cdfc74)。
[root@dsrw ~]# nmcli connection delete school
成功删除连接 "school" (130da14d-5922-4f3a-8971-8adc2cff6fd6)。
[root@dsrw ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens160 04fe9326-bf57-44b8-9ef3-54f0db2498c3 ethernet ens160
virbr0 0e7e9f6c-d6db-4ec3-a75d-348eda35db6f bridge virbr0
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
请登录后查看评论内容