centos 7 物理机添加虚拟网卡

1. 确认内核是否支持tun/tap
确认内核是否有tun模块

[root@VM_196_26_centos ~]# modinfo tun

filename:       /lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/net/tun.ko

alias:          devname:net/tun

alias:          char-major-10-200

license:        GPL

author:         (C) 1999-2004 Max Krasnyansky

description:    Universal TUN/TAP device driver

rhelversion:    7.2

srcversion:     B59BCB1255A36FBC7557FC3

depends:        

intree:         Y

vermagic:       3.10.0-327.el7.x86_64 SMP mod_unload modversions 

signer:         CentOS Linux kernel signing key

sig_key:        79:AD:88:6A:11:3C:A0:22:35:26:33:6C:0F:82:5B:8A:94:29:6A:B3

sig_hashalgo:   sha256

加载内核模块

[root@VM_196_26_centos ~]# modprobe tun

[root@VM_196_26_centos ~]# lsmod | grep tun

tun                    27141  0 

执行以上命令后,出现如上输出,说明模块加载成功

2. 创建和配置虚拟网卡
确认是否有tunctl命令,如果没有通过yum安装即可

centos6通过直接通过yum install tunctl -y安装

(以上参考的http://www.jb51.net/LINUXjishu/401735.html

centos7安装可直接装rpm包(参考的https://pkgs.org/centos-7/nux-misc-x86_64/tunctl-1.5-12.el7.nux.x86_64.rpm.html

root@VM_196_26_centos ~]# tunctl -t tap0 -u root

Set ‘tap0‘ persistent and owned by uid 0

[root@VM_196_26_centos ~]# ifconfig tap0 192.168.0.1 netmask 255.255.255.0 promisc

[root@VM_196_26_centos ~]# ifconfig tap0


你可能感兴趣的:(centos 7 物理机添加虚拟网卡)