码迷,mamicode.com
首页 > 其他好文 > 详细

RHEL7 添加网卡并设置多个IP地址

时间:2017-08-25 01:06:08      阅读:1562      评论:0      收藏:0      [点我收藏+]

标签:forever   seq   信息   fas   pack   技术   ping   style   log   

首先在虚拟机管理界面中给该虚拟机添加一块虚拟网卡,VirtualBox虚拟机中要shutdown才能添加。

技术分享

[root@rhel7 ~]# nmcli device show | grep -i device   --查看网卡设备,我们可以看到新添加的enp0s8
GENERAL.DEVICE:                         virbr0
GENERAL.DEVICE:                         enp0s3
GENERAL.DEVICE:                         virbr0-nic
GENERAL.DEVICE:                         enp0s8
GENERAL.DEVICE:                         lo
[root@rhel7 ~]# nmcli connection show     ---还得添加网卡配置文件才能查看到enp0s8
NAME        UUID                                  TYPE            DEVICE     
virbr0-nic  c6a02e0f-24af-4b3b-983d-1643fee355df  generic         virbr0-nic 
virbr0      eecfd3a6-4d29-4f9c-a62c-1a30df56e011  bridge          virbr0     
enp0s3      df34c879-c2bd-4c82-ae7a-39e39a2228dd  802-3-ethernet  enp0s3     

添加enp0s8的网卡配置文件:

[root@rhel7 ~]# nmcli connection add type ethernet con-name enp0s8 ifname enp0s8 autoconnect yes
Connection enp0s8 (8bf108aa-9c89-4c2c-a5d3-3d9346b2c644) successfully added.
[root@rhel7 ~]# nmcli connection show
NAME        UUID                                  TYPE            DEVICE     
virbr0-nic  c6a02e0f-24af-4b3b-983d-1643fee355df  generic         virbr0-nic 
virbr0      eecfd3a6-4d29-4f9c-a62c-1a30df56e011  bridge          virbr0     
enp0s3      df34c879-c2bd-4c82-ae7a-39e39a2228dd  802-3-ethernet  enp0s3     
enp0s8      8bf108aa-9c89-4c2c-a5d3-3d9346b2c644  802-3-ethernet  enp0s8     

配置IP地址及其它信息:

[root@rhel7 ~]# nmcli connection modify enp0s8  ipv4.addresses 192.168.1.200/24 ipv4.gateway 192.168.1.99  ipv4.dns 192.168.1.1 ipv4.method manual connection.autoconnect yes

启动enp0s8网卡:

[root@rhel7 ~]# nmcli connection up enp0s8
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)
[root@rhel7 ~]# ip a s enp0s8
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:79:3c:2c brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.200/24 brd 192.168.1.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe79:3c2c/64 scope link 
       valid_lft forever preferred_lft forever

网卡添加配置完成。

============================

给enp0s8再配置一个IP地址192.168.1.201:

[root@rhel7 ~]# nmcli connection modify enp0s8 +ipv4.addresses 192.168.1.201/24 ipv4.gateway 192.168.1.99
[root@rhel7 ~]# nmcli connection down enp0s8   --重启网卡
Connection enp0s8 successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)
[root@rhel7 ~]# nmcli connection up enp0s8
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14)
[root@rhel7 ~]# nmcli connection show 
NAME        UUID                                  TYPE            DEVICE     
virbr0-nic  c6a02e0f-24af-4b3b-983d-1643fee355df  generic         virbr0-nic 
virbr0      eecfd3a6-4d29-4f9c-a62c-1a30df56e011  bridge          virbr0     
enp0s3      df34c879-c2bd-4c82-ae7a-39e39a2228dd  802-3-ethernet  enp0s3     
enp0s8      8bf108aa-9c89-4c2c-a5d3-3d9346b2c644  802-3-ethernet  enp0s8     
[root@rhel7 ~]# ip addr show enp0s8 --查看添加成功
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:79:3c:2c brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.200/24 brd 192.168.1.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet 192.168.1.201/24 brd 192.168.1.255 scope global secondary enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe79:3c2c/64 scope link 
       valid_lft forever preferred_lft forever
[root@rhel7 ~]# 

 给enp0s8再配置一个IPv6地址2001::1/64

[root@rhel7 ~]# nmcli connection modify enp0s8  ipv6.method manual ipv6.addresses 2001::1/64  ipv6.gateway 2001::1 ipv6.dns 2001::1
[root@rhel7 ~]# ping6 2001::1
connect: Network is unreachable
[root@rhel7 ~]# nmcli connection down enp0s8
Connection enp0s8 successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14)
[root@rhel7 ~]# nmcli connection up enp0s8
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/15)
[root@rhel7 ~]# ping6 2001::1
PING 2001::1(2001::1) 56 data bytes
64 bytes from 2001::1: icmp_seq=1 ttl=64 time=0.062 ms
64 bytes from 2001::1: icmp_seq=2 ttl=64 time=0.116 ms
64 bytes from 2001::1: icmp_seq=3 ttl=64 time=0.119 ms
^C
--- 2001::1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.062/0.099/0.119/0.026 ms
[root@rhel7 ~]# 

 

RHEL7 添加网卡并设置多个IP地址

标签:forever   seq   信息   fas   pack   技术   ping   style   log   

原文地址:http://www.cnblogs.com/rusking/p/7425935.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!