SOLUTION VERIFIED

environment

  • Red Hat Enterprise Linux 4
  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7

question

  • 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?

solution

RHEL 7 with NetworkManager

  • With nmcli, create a new connection of the VLAN type where con-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, and id 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

  • Create an interface configuration file in the /etc/sysconfig/network-scripts/ directory with the name ifcfg-{name} where {name} is the custom name for the VLAN interface.
  • The ifcfg file must include: the DEVICE parameter which specifies the custom interface name, the PHYSDEV parameter which specifies the interface the VLAN will be on top of, VID which specifies the VLAN ID (number), and VLAN=yes must be set. PHYSDEV can be a bond.
  • In the following example, a VLAN interface named "outside-network" will be created over eth0 with a VLAN ID of 10:
    DEVICE=outside-network
    VLAN=yes
    PHYSDEV=eth0
    VID=10
    BOOTPROTO=dhcp
    ONBOOT=yes
    # This became possible in RHEL 6 with the release of initscripts-9.03.46-1.el6: RHBA-2014:1448-1

Set up VLAN (802.1q) tagging on a network interface?的更多相关文章

  1. vlan 以及 Linux实现的IEEE 802.1Q VLAN

    vlan 以及 Linux实现的IEEE 802.1Q VLAN Vlan的概念 VLAN技术介绍 VLANVLAN概述 以太网是一种基于CSMA/CD(Carrier Sense Multiple ...

  2. 802.1Q VLAN技术原理

    文章出处:http://hi.baidu.com/x278384/item/d56b0edfd4f56a4eddf9be79 在数据通信和宽带接入设备里,只要涉及到二层技术的,就会遇到VLAN.而且, ...

  3. 管理型交换机IEEE 802.1Q VLAN设置应用实例

    转载标注: IEEE802.1Q 我粗略理解为对交换机入口规则和出口规则设置,入口打上VID,设置从哪些口可以出去,并且是否带标签. 一 VLAN的概念 VLAN(Virtual Local Area ...

  4. 802.1q VLAN

    VLAN(Virtual Local Area Network),是一种通过将局域网内的设备逻辑地而不是物理地划分成一个个网段从而实现虚拟工作组的技术. 以一个网络接口为主设备,可以创建多个虚拟网络接 ...

  5. 如何在centos上配置802.1Q VLAN标记,linux单网卡多vlan多网段Ip配置案例

    介绍 VLAN使将大型网络分成较小且易于管理的网络成为可能.802.1Q是所有供应商都在其网络设备中实施的标准.某些交换机能够将多个VLAN分配给单个网络端口.使用此功能,您可以将多个VLAN分配给单 ...

  6. 网络工程知识(二)VLAN的基础和配置:802.1q帧;Access、Trunk、Hybrid接口工作模式过程与配置;VLANIF的小实验

    介绍-VLAN VLAN(Virtual Local Area Network)即虚拟局域网,工作在数据链路层. 交换机将通过:接口.MAC.基于子网.协议划分(IPv4和IPv6).基于策略的方式划 ...

  7. VLAN IEEE802.1Q

    一. VLAN产生原因-广播风暴 传统的局域网使用的是HUB,HUB只有一根总线,一根总线就是一个冲突域.所以传统的局域网是一个扁平的网络,一个局域网属于同一个冲突域.任何一台主机发出的报文都会被同一 ...

  8. 【vlan-trunk和802.1q子接口配置】

    根据项目需求,搭建好拓扑图如下: 配置sw1的g1/0/3的/trunk,把g1/0/1和g1/0/2分别加入vlan 10 和 vlan 20 配置sw1的g1/0/3的/trunk,把g1/0/1 ...

  9. VLAN-3-VLAN Trunk:ISL和802.1Q

      (1)ISL和802.1Q概念       通过使用VLAN Trunk链路,设备可以通过一条链路发送去往多个vlan的流量.为了知道数据帧属于哪个vlan,发送方会添加原始以太网数据帧的头部,这 ...

随机推荐

  1. 关于.NET异常处理的思考

    年关将至,对于大部分程序员来说,马上就可以闲下来一段时间了,然而在这个闲暇的时间里,唯有争论哪门语言更好可以消磨时光,估计最近会有很多关于java与.net的博文出现,我表示要作为一个吃瓜群众,静静的 ...

  2. IE6/7下空div占用空间的问题

    最近注意力没在前端上面,工作碰到这样一个问题,下意识的写了句 font-size:0;line-height:0;哪知道引发了更大的bug.后来插入数据进去的时候都不显示了..再后来百度一番找到,原来 ...

  3. Code Review 程序员的寄望与哀伤

    一个程序员,他写完了代码,在测试环境通过了测试,然后他把它发布到了线上生产环境,但很快就发现在生产环境上出了问题,有潜在的 bug. 事后分析,是生产环境的一些微妙差异,使得这种 bug 场景在线下测 ...

  4. 简单有效的kmp算法

    以前看过kmp算法,当时接触后总感觉好深奥啊,抱着数据结构的数啃了一中午,最终才大致看懂,后来提起kmp也只剩下“奥,它是做模式匹配的”这点干货.最近有空,翻出来算法导论看看,原来就是这么简单(先不说 ...

  5. 模拟AngularJS之依赖注入

    一.概述 AngularJS有一经典之处就是依赖注入,对于什么是依赖注入,熟悉spring的同学应该都非常了解了,但,对于前端而言,还是比较新颖的. 依赖注入,简而言之,就是解除硬编码,达到解偶的目的 ...

  6. Asp.Net WebApi核心对象解析(上篇)

    生活需要自己慢慢去体验和思考,对于知识也是如此.匆匆忙忙的生活,让人不知道自己一天到晚都在干些什么,似乎每天都在忙,但又好似不知道自己到底在忙些什么.不过也无所谓,只要我们知道最后想要什么就行.不管怎 ...

  7. ThinkPHP+Smarty模板中截取包含中英文混合的字符串乱码的解决方案

    好几天没写博客了,其实有好多需要总结的,因为最近一直在忙着做项目,但是困惑了几天的Smarty模板中截取包含中英文混合的字符串乱码的问题,终于解决了,所以记录下来,需要的朋友看一下: 出现乱码的原因: ...

  8. Javascript 严格模式详解

    转自http://www.ruanyifeng.com/blog/2013/01/javascript_strict_mode.html 一.概述 除了正常运行模式,ECMAscript 5添加了第二 ...

  9. SpringMVC初始化参数绑定--日期格式

    一.初始化参数绑定[一种日期格式] 配置步骤: ①:在applicationcontext.xml中只需要配置一个包扫描器即可 <!-- 包扫描器 --> <context:comp ...

  10. C++常考面试题汇总

    c++面试题 一 用简洁的语言描述 c++ 在 c 语言的基础上开发的一种面向对象编程的语言: 应用广泛: 支持多种编程范式,面向对象编程,泛型编程,和过程化编程:广泛应用于系统开发,引擎开发:支持类 ...