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

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

# 创建一个名为bond1的绑定接口,使用active-backup模式,并设置每100毫秒监控一次链路状态 ip link add bond1 type bond miimon 100 mode active-backup # 将eth0接口添加到绑定接口bond1 ip link set eth0 master bond1 # 将eth1接口添加到绑定接口bond1 ip 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接口添加到团队设备team0
teamdctl team0 port add eth0
# 将eth1接口添加到团队设备team0
teamdctl team0 port add eth1VLAN

# 在eth0接口上创建一个VLAN ID为2的子接口eth0.2 ip link add link eth0 name eth0.2 type vlan id 2 # 在eth0接口上创建一个VLAN ID为3的子接口eth0.3 ip 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作为承载接口,目的端口为4789 ip 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,连接到eth0 ip 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的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号