http://www.microhowto.info/tutorials/802.1q.html

Configure an Ethernet interface as a VLAN trunk

host需要连接2个 VLANs, 192.168.2.1/24 on VLAN 2 and 192.168.3.1/24 on VLAN 3

# modprobe 8021q

# lsmod | grep 8021q

3种方法:

1 通过配置文件

auto eth0.

iface eth0. inet static

  address 192.168.2.1

  netmask 255.255.255.0

auto eth0.

iface eth0. inet static

  address 192.168.3.1

  netmask 255.255.255.0
ifup eth0.
ifup eth0.
ifconfig eth0.

eth0.    Link encap:Ethernet  HWaddr :::::
inet addr:192.168.2.1 Bcast:12.168.2.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (0.0 b) TX bytes: (0.0 b)

如果需要指定连到那个物理网卡:

auto vlan2
iface vlan2 inet static
address 192.168.2.1
netmask 255.255.255.0
vlan-raw-device eth0

http://www.microhowto.info/tutorials/802.1q.html

2 Vconfig

vconfig add eth0
vconfig add eth0
# ifconfig eth0. 192.168.2.1 netmask 255.255.255.0 broadcast 192.168.2.255 up

# ifconfig eth0. 192.168.3.1 netmask 255.255.255.0 broadcast 192.168.3.255 up

获取VLAN interface的详细信息

# cat /proc/net/vlan/eth0.5

删除VLAN interface

# ifconfig eth0. down
# vconfig rem eth0.

3 通过ip

# ip link add link eth0 name eth0. type vlan id
# ip link
# ip -d link show eth0. # ip addr add 192.168.2.1/ brd 192.168.2.255 dev eth0.
# ip link set dev eth0. up

删除:

# ip link set dev eth0. down
# ip link delete eth0.

配置完后,来ping eth0的ip,会发生eth0可以收到并回复,但eth0.2收到但不回复。

http://blog.csdn.net/suiyuan19840208/article/details/8221529

配置网卡为vlan trunk的更多相关文章

  1. vlan trunk配置

    vlan trunk配置 Trunk:中继干道 作用:一条链路能承载多个vlan的流量,并对不同vlan的流量进行不同标记 trunk能够使vlan跨越交换机 PT配置 配置vlan:两台交换机同样的 ...

  2. 2.1-VLAN/TRUNK/VTP

    2.1-VLAN/TRUNK/VTP     注意:配置VLAN时要退出VLAN配置模式才会执行 如果VLAN被删除或者shutdown,那么属于这个vlan的接口将被阻塞(灯一直是橙色,变不了绿色) ...

  3. 网卡添加VLAN TAG

    #modprobe 8021q 用命令 lsmod | grep 8021q 来检查 以配置网卡eth0为例,添加vlan号:1002 ================================ ...

  4. vtp——vlan trunk protcal

    server模式——服务器模式,在该模式下可以建立vlan,删除vlan,该模式下的vlan可以下发到其他的交换机 client模式——客户端模式,被动模式.交换机可以接受从server模式下传来的v ...

  5. Cisco 的基本配置实例之四----vlan的规划及配置(接入交换机)

    4.2 接入交换机的相关配置 ## 在此例中,我们联入的是一台接入交换机,此交换机的gi0/1口上联至核心交换机.也就意味着我们需要配置gi0/1为trunk口.具体的配置如下: D-2960-3(c ...

  6. 实验13:VLAN/TRUNK/VTP/

    实验10-1: 划分VLAN Ø    实验目的通过本实验,读者可以掌握如下技能:(1) 熟悉VLAN 的创建(2) 把交换机接口划分到特定VLAN Ø    实验拓扑 实验步骤要配置VLAN,首先要 ...

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

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

  8. linux配置网卡IP地址命令详细介绍及一些常用网络配置命令

    linux配置网卡IP地址命令详细介绍及一些常用网络配置命令2010-- 个评论 收藏 我要投稿 Linux命令行下配置IP地址不像图形界面下那么方 便,完全需要我们手动配置,下面就给大家介绍几种配置 ...

  9. RedHat5配置网卡

    RedHat5配置网卡过程: 1.vi /etc/sysconfig/network-scripts/ifcfg-eth0 2.将hdcp修改成static 3.最后添加 IPADDR=192.168 ...

随机推荐

  1. Service Name Port Number Transport Protocol tcp udp 端口号16bit

    https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol The DHCP employs a connectionless  ...

  2. Markov Process

    w Markov Process -- from Wolfram MathWorld  http://mathworld.wolfram.com/MarkovProcess.html 谷歌背后的数学_ ...

  3. <2013 12 17> 专业技能

    Specialties: • Mechanical design modeling using Pro/ENGINEER and SolidWorks.• Robot control, path pl ...

  4. 博客没内容可写了怎么办?找BD!

    博客写了一段时间可能会感觉没内容可以写了,或者说同一个领域的内容写多了感觉有点千篇一律,这时要考虑扩展自己的写作领域,怎么去扩展呢?利用关键词工具可以衍生很多长尾词,当然这个有点牵强,有点为优化而优化 ...

  5. opencv3计算机视觉+Python(一)

    基本I/O脚本 读/写图像文件 OpenCV的imread函数和imwrite函数能支持各种静态图像文件格式.不同系统支持的文件格式不一样,但都支持BMP格式,通常还应该支持PNG.JPEG和TIFF ...

  6. python如何实现多线程

    一个线程就是一个轻量级进程,多线程能让我们一次执行多个线程. python是多线程语言,其内置有多线程工具包 python中GIL(全局解释器锁)确保一次执行单个线程.一个线程保存GIL并在将其传递给 ...

  7. active admin

    activeadmin 1.0.0.pre4 所依赖的库 gem 'jquery-rails', '~> 4.0.4' 4.2版本会出现找不到jquery-ui 的datepicker错误 使用 ...

  8. grep的若干用法

    查找包含server或者client的行 egrep 'server|client' file-name /usr/xpg4/bin/grep -E 'server|client' file-name ...

  9. pppoe白皮书

    转:https://blog.csdn.net/achejq/article/details/19478811 PPPoE技术白皮书 关键词:PPP,Ethernet,PPPoE 摘    要:PPP ...

  10. 支持鼠标拖拽滑动的jQuery焦点图

    在线演示 本地下载