How do I set up VLAN (802.1q) tagging on a network interface?
环境
- Red Hat Enterprise Linux 4
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
问题
- Suppose I want a VLAN ID of 192 for the eth0 on a RHEL 5 or 6 system. What should my ifcfg-eth0 and my ifcfg-eth0.192 look like?
- How do you configure VLAN tagging on a RHEL system?
- Is it possible to configure multiple VLAN IDs on a single interface?
决议
RHEL 7 with NetworkManager
-
With
nmcli
, create a new connection of the VLAN type wherecon-name
is the name of the connection,ifname
is the name of the VLAN interface to be created,master
is the name of the interface the VLAN will be on top of, andid
is the VLAN ID (number). -
Using DHCP for IP addressing with a VLAN ID of 10:
# nmcli connection add type vlan ifname eth0.10 con-name myvlan id 10 dev eth0
- Or, with a static IP using example IP address 192.168.1.10/24 and gateway of 192.168.1.1:
# nmcli connection add type vlan ifname eth0.10 con-name myvlan id 10 dev eth0 ip4 192.168.1.10/24 gw4 192.168.1.1
RHEL 4, RHEL 5, RHEL 6, and RHEL 7 without NetworkManager
- Create an interface configuration file in the /etc/sysconfig/network-scripts/ directory with the name ifcfg-{device}.{vlan} where {device} is the interface the VLAN will be on top of and {vlan} is the VLAN ID (number). {device} can be either a regular interface or a bond. In the example below, the file would be called
ifcfg-eth0.10
. - The ifcfg file must include the DEVICE parameter which specifies the VLAN interface name and VLAN=yes must be set:
DEVICE=eth0.10
VLAN=yes
BOOTPROTO=dhcp
ONBOOT=yes
RHEL 6 with a custom VLAN interface name
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· Open-Sora 2.0 重磅开源!
2019-09-17 centos7 如何使用ReaR进行系统备份(如何使用NFS方法设置ReaR备份)