在osi模型的定义中,数据链路层和物理层,以及传输层和网络层执行的任务在概念上相似:它们都提供了数据传输的方式,即沿着特定路径将数据从源点传输到目的地的方法。然而,数据链路层和物理层负责跨物理路径的通信服务,而传输层和网络层则提供由多个数据链路组成的逻辑路径或虚拟路径的通信服务。
Bridge操作指令

# 创建一个名为br0的桥接设备ip link add br0 type bridge# 将eth0接口添加到桥接设备br0ip link set eth0 master br0# 将tap1接口添加到桥接设备br0ip link set tap1 master br0# 将tap2接口添加到桥接设备br0ip link set tap2 master br0# 将veth1接口添加到桥接设备br0ip link set veth1 master br0
Bonded interface

# 创建一个名为bond1的绑定接口,使用active-backup模式,并设置每100毫秒监控一次链路状态ip link add bond1 type bond miimon 100 mode active-backup# 将eth0接口添加到绑定接口bond1ip link set eth0 master bond1# 将eth1接口添加到绑定接口bond1ip link set eth1 master bond1
Team device

# 启动teamd守护进程,创建名为team0的团队设备,配置为activebackup模式,使用ethtool监控链路状态teamd -o -n -U -d -t team0 -c '{"runner": {"name": "activebackup"},"link_watch": {"name": "ethtool"}}'# 关闭eth0接口ip link set eth0 down# 关闭eth1接口ip link set eth1 down# 将eth0接口添加到团队设备team0teamdctl team0 port add eth0# 将eth1接口添加到团队设备team0teamdctl team0 port add eth1
VLAN

# 在eth0接口上创建一个VLAN ID为2的子接口eth0.2ip link add link eth0 name eth0.2 type vlan id 2# 在eth0接口上创建一个VLAN ID为3的子接口eth0.3ip link add link eth0 name eth0.3 type vlan id 3
VXLAN



# 创建一个VXLAN隧道设备vx0,设置VNI为100,本地IP为1.1.1.1,远程IP为2.2.2.2,使用eth0作为承载接口,目的端口为4789ip link add vx0 type vxlan id 100 local 1.1.1.1 remote 2.2.2.2 dev eth0 dstport 4789
MACVLAN






# 创建一个MACVLAN接口macvlan1,连接到eth0,使用桥接模式ip link add macvlan1 link eth0 type macvlan mode bridge# 创建一个MACVLAN接口macvlan2,连接到eth0,使用桥接模式ip link add macvlan2 link eth0 type macvlan mode bridge# 创建一个名为net1的网络命名空间ip netns add net1# 创建一个名为net2的网络命名空间ip netns add net2# 将macvlan1接口移动到net1网络命名空间ip link set macvlan1 netns net1# 将macvlan2接口移动到net2网络命名空间ip link set macvlan2 netns net2
IPVLAN



# 创建一个名为ns0的网络命名空间ip netns add ns0# 创建一个IPVLAN接口ipvl0,连接到eth0,使用L2模式ip link add name ipvl0 link eth0 type ipvlan mode l2# 将ipvl0接口移动到ns0网络命名空间ip link set dev ipvl0 netns ns0
MACVTAP/IPVTAP

# 创建一个MACVTAP接口macvtap0,连接到eth0ip link add link eth0 name macvtap0 type macvtap
VETH

# 创建一个名为net1的网络命名空间ip netns add net1# 创建一个名为net2的网络命名空间ip netns add net2# 创建一对VETH设备veth1和veth2,分别移动到net1和net2网络命名空间ip link add veth1 netns net1 type veth peer name veth2 netns net2
参考:
https://www.php.cn/link/e3133801456d68c42114514a81db864b
https://www.php.cn/link/2842db40fd1da44e0be74335fb55004d
https://www.php.cn/link/bd44f20ee6ac130433c642094cecd336
以上就是Linux interfaces 虚拟网络类型了解01的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/23288.html
微信扫一扫
支付宝扫一扫