RHEL7 配置临时IP 测试

RHEL7 配置或添加临时IP地址测试:

[root@rhel7 Desktop]# ip a s enp0s3  ---查看原网卡IP 为192.168.1.7
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:73:7a:97 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.7/24 brd 192.168.1.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe73:7a97/64 scope link 
       valid_lft forever preferred_lft forever
[root@rhel7 Desktop]# ifconfig enp0s3 192.168.1.8 ---设置临时ip为192.168.1.8
[root@rhel7 Desktop]# ip a s enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:73:7a:97 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.8/24 brd 192.168.1.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe73:7a97/64 scope link 
       valid_lft forever preferred_lft forever
[root@rhel7 Desktop]# ip addr add dev enp0s3 192.168.1.222 --添加一个临时ip 192.168.1.222
[root@rhel7 Desktop]# ip a s enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:73:7a:97 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.8/24 brd 192.168.1.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet 192.168.1.222/32 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe73:7a97/64 scope link 
       valid_lft forever preferred_lft forever
[root@rhel7 Desktop]# nmcli connection down enp0s3  --重启网卡后恢复为原来的IP192.168.1.7
Connection 'enp0s3' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[root@rhel7 Desktop]# nmcli connection up enp0s3 
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[root@rhel7 Desktop]# ip a s enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:73:7a:97 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.7/24 brd 192.168.1.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe73:7a97/64 scope link 
       valid_lft forever preferred_lft forever
[root@rhel7 Desktop]# 

 

posted on 2017-08-24 23:12  遠離塵世の方舟  阅读(747)  评论(0编辑  收藏  举报

导航