标签:device ref free status start 支持 环境 loopback pac
实验1
网卡支持多会话功能,由于工作环境不同,需要配置不同的网络:如在家里使用使用DHCP获取,在公司使用固定ip,如果使用修改方式比较麻烦,配置多会话功能,在不同场景激活即可。
实验环境:
centos7、home:DHCP、company:static,自动连接
配置过程:配置信息会保存至/etc/sysconfig/network-scripts/ifcfg-name
[root@xt ~]# nmcli connection add con-name company autoconnect yes ifname ens36 type ethernet
Connection ‘company‘ (46f14092-152e-4af3-9273-5acbf573b2a2) successfully added.
[root@xt ~]# nmcli connection add con-name home autoconnect no ifname ens36 type ethernet
Connection ‘home‘ (d3c8a326-e494-47b9-b6ea-92f18998b9b6) successfully added.
[root@xt ~]# nmcli connection show
NAME UUID TYPE DEVICE
eno16777736 2361aff4-2de8-4868-9fd6-5d30ccdada02 802-3-ethernet eno16777736
home d3c8a326-e494-47b9-b6ea-92f18998b9b6 802-3-ethernet --
company 46f14092-152e-4af3-9273-5acbf573b2a2 802-3-ethernet ens36
[root@xt ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
eno16777736 ethernet connected eno16777736
ens36 ethernet connected company
lo loopback unmanaged --
修改IP地址
如果不修改默认为自动分配;
[root@xt ~]# nmcli connection modify company ipv4.addresses 172.16.0.10/16 ipv4.method manual
还可以配置DNS、gateway...
[root@xt ~]# systemctl restart network #重启服务
[root@xt ~]# nmcli device status #ens36当前自动连接至company会话
DEVICE TYPE STATE CONNECTION
eno16777736 ethernet connected eno16777736
ens36 ethernet connected company
lo loopback unmanaged --
[root@xt ~]# ifconfig ens36 #ens36的ip信息配置正常
ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.0.10 netmask 255.255.0.0 broadcast 172.16.255.255
inet6 fe80::20c:29ff:fe20:b507 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:20:b5:07 txqueuelen 1000 (Ethernet)
RX packets 187 bytes 23730 (23.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 88 bytes 10998 (10.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@xt ~]# nmcli connection up home #将网卡会话切换至home会话
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9)
[root@xt ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
eno16777736 ethernet connected eno16777736
ens36 ethernet connected home #ens36当前会话状态
lo loopback unmanaged --
[root@xt ~]# ifconfig ens36 #此时ip信息是自动获取
ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.175.133 netmask 255.255.255.0 broadcast 192.168.175.255
inet6 fe80::20c:29ff:fe20:b507 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:20:b5:07 txqueuelen 1000 (Ethernet)
RX packets 190 bytes 24476 (23.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 98 bytes 12306 (12.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
标签:device ref free status start 支持 环境 loopback pac
原文地址:http://blog.51cto.com/12580678/2339170