博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
RHEL7 添加网卡并设置多个IP地址
阅读量:5908 次
发布时间:2019-06-19

本文共 4387 字,大约阅读时间需要 14 分钟。

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

[root@rhel7 ~]# nmcli device show | grep -i device   --查看网卡设备,我们可以看到新添加的enp0s8GENERAL.DEVICE:                         virbr0GENERAL.DEVICE:                         enp0s3GENERAL.DEVICE:                         virbr0-nicGENERAL.DEVICE:                         enp0s8GENERAL.DEVICE:                         lo[root@rhel7 ~]# nmcli connection show     ---还得添加网卡配置文件才能查看到enp0s8NAME        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 yesConnection 'enp0s8' (8bf108aa-9c89-4c2c-a5d3-3d9346b2c644) successfully added.[root@rhel7 ~]# nmcli connection showNAME        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 enp0s8Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)[root@rhel7 ~]# ip a s enp0s83: enp0s8: 
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 enp0s8Connection 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: 
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::1connect: Network is unreachable[root@rhel7 ~]# nmcli connection down enp0s8Connection 'enp0s8' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14)[root@rhel7 ~]# nmcli connection up enp0s8Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/15)[root@rhel7 ~]# ping6 2001::1PING 2001::1(2001::1) 56 data bytes64 bytes from 2001::1: icmp_seq=1 ttl=64 time=0.062 ms64 bytes from 2001::1: icmp_seq=2 ttl=64 time=0.116 ms64 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 2000msrtt min/avg/max/mdev = 0.062/0.099/0.119/0.026 ms[root@rhel7 ~]#

 

转载地址:http://kkvpx.baihongyu.com/

你可能感兴趣的文章
SHELL 自动备份MYSQL数据库(备份单个数据库及所有数据库)
查看>>
我的友情链接
查看>>
linux修改IP和DNS
查看>>
windows下安装redis
查看>>
Python基础5 常用模块
查看>>
我的友情链接
查看>>
vi/vim多窗口编辑相关命令
查看>>
IntelliJ IDEA 安装 Scala 插件
查看>>
一台主机部署多个mysqld实例配置
查看>>
通过案例学调优之--跨库建立物化视图(Materialized View)
查看>>
WordPress新增Page的模版文件
查看>>
JAVAWEB应用的policy安全配置值得深思
查看>>
软件系统架构师成长之路(一)
查看>>
Android火焰效果程序(有图有源码)
查看>>
Appium自动化测试系列2- 写一个Python测试脚本来测试一下YY语音
查看>>
C#利用反射开发插件
查看>>
我的友情链接
查看>>
IBM X3650M2远程管理卡配置及连接
查看>>
Binder原理学习记录
查看>>
repadmin 最佳管理工具
查看>>