博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tunctl used & bridge sub interface network used with multi-network env
阅读量:6305 次
发布时间:2019-06-22

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

虚拟网络接口的创建和使用, 另外如果使用了网桥的情况下, 虚拟机如果配置的网段和主机不同, 并且没有trunk口没有路由器的情况下, 虚拟机和主机之间通讯的方法.
安装tunctl
# yum install -y tunctl
添加一个虚拟网络设备
# tunctl -u nobody -g nobody -t tap0 -p
将虚拟网络设备激活
# ifconfig tap0 up
查看链路状态
# ip link 15: tap0: 
mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500 link/ether 5a:6c:f8:ee:ad:5b brd ff:ff:ff:ff:ff:ff
将虚拟网络设备添加到网桥
# brctl addif ovirtmgmt tap0
将虚拟网络设备从网桥删除
# brctl delif ovirtmgmt tap0
删除一个虚拟网络设备
# tunctl -d tap0
当一个网桥中有多个IP段需要使用时, 并且没有路由器的情况下, 如果要通讯的话, 需要在主机上配置多个网段, 相同网段之间进行通讯. 
配置网桥的子接口IP
# cd /etc/sysconfig/network-scripts/# brctl showbridge name     bridge id               STP enabled     interfaces;vdsmdummy;             8000.000000000000       noovirtmgmt               8000.00221960778f       no              em1                                                        vnet0# cp ifcfg-ovirtmgmt ifcfg-ovirtmgmt:1# vi ifcfg-ovirtmgmt:1DEVICE=ovirtmgmt:1BOOTPROTO=staticONBOOT=yesBROADCAST=172.16.13.255IPADDR=172.16.13.150NETMASK=255.255.255.0NM_CONTROLLED=no
例如 :
HOSTA - if0(172.16.3.0/24, 172.16.13.0/24)HOSTB - if0(172.16.3.0/24, 172.16.13.0/24)VMA - if0(172.16.13.0/24)VMB - if0(172.16.13.0/24)
以上都可以相互通讯.

[参考]
1. man tunctl
[root@150 network-scripts]# man tunctlTUNCTL(8)                                                            TUNCTL(8)NAME       tunctl - create and manage persistent TUN/TAP interfacesSYNOPSIS       tunctl [ OPTIONS ]  [ -u owner ]  [ -t device-name ]       tunctl -d device-nameDESCRIPTION       tunctl allows the host sysadmin to preconfigure a TUN/TAP network interface for use by a particular user.  That       user may open and use the network/write side of the interface, but may not change any aspects of the host  side       of the interface.OPTIONS       -b     Brief output, prints just the interface name       -n     Create  a  point-to-point  TUN  interface without Ethernet header.  Automatically enabled if the desired              interface name starts with "tun".       -p     Create a TAP type interface with Ethernet header. Automatically selected if the desired interface starts              with "tap" or if no interface name is given.       -f tun-clone-device              Specifies the tun clone device name. The default is /dev/net/tun, but some systems use /dev/misc/net/tun              instead.       -d interfacename              Delete the specified interfacename (set it to non-persistent)       -u user              Specifies the owner of the interface. This user is allowed to attach to the "network/wire" side.       -g group              Specifies the group of the interface. This group is allowed to attach to the "network/wire" side of  the              interface.       -t interface              Specifies the desired interface name.USAGE       To create an interface for use by a particular user, invoke tunctl without the -d option:               # tunctl -u someuser               Set ’tap0’ persistent and owned by ’someuser’       Then, configure the interface as normal:               # ifconfig tap0 192.168.0.254 up               # route add -host 192.168.0.253 dev tap0               # bash -c ’echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp’               # arp -Ds 192.168.0.253 eth0 pub       To delete the interface, use the -d option:               # tunctl -d tap0               Set ’tap0’ nonpersistentSEE ALSO       The UserModeLinux-HOWTO 
AUTHOR tunctl was originally written by Jeff Dike
as part of the User Mode Linux tools. Current version is maintained as a separate package by Henrik Nordstrom
. This manual page was originally written by Matt Zimmerman
for the Debian GNU/Linux system, based on examples from Jeff Dike. Extended by Henrik Nordstrom
to cover all options supported. July 9, 2008 TUNCTL(8)

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

你可能感兴趣的文章
小程序之时间戳转为时间
查看>>
关押罪犯
查看>>
k8s-高可用架构设计
查看>>
第93天:CSS3 中边框详解
查看>>
第189天:BOM属性方法
查看>>
操作系统
查看>>
volatile小记
查看>>
Socket通道
查看>>
如何让网上应聘更有效
查看>>
对失败项目的思考
查看>>
bzoj 2982 combination——lucas模板
查看>>
浪潮之巅第十四章 — 科技公司的吹鼓手:投资银行
查看>>
矩形的UISearchBar
查看>>
0,快速教程
查看>>
用css来实现标题内容超出长度范围自动省略,且有鼠标提示
查看>>
网站集成QQ登录功能
查看>>
openstack网络基础
查看>>
手机连接wamp网页
查看>>
敏捷开发学习笔记——产品经理
查看>>
POJ1017 Packets(贪心)
查看>>