http://minitoo.blog.51cto.com/4201040/786011(转载)

在路由器上做单臂路由实现VLAN间路由,也就是设置子接口和封装协议。

实现环境如下图:

  1. 在交换机上建立VLAN,并将交换机的各端口按部门划分到各VLAN。

Switch>enable

Switch#config terminal

Switch(config)#vlan 2

Switch(config-vlan)#name shengchan

Switch(config-vlan)#exit

Switch(config)#vlan 3

Switch(config-vlan)#name xiaoshou

Switch(config-vlan)#exit

Switch(config)#vlan 4

Switch(config-vlan)#name xingzheng

Switch(config-vlan)#exit

Switch(config)#interface fastethernet 0/1

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 2

Switch(config-if)#exit

Switch(config)#interface fastethernet 0/2

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 3

Switch(config-if)#exit

Switch(config)#interface fastethernet 0/3

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 4

Switch(config-if)#exit

  1. 在交换机连接路由器的接口上配置TRUNK,并使TRUNK传输所有的VLAN的数据包。

Switch(config)#interface fastethernet 0/4

Switch(config-if)#switchport mode trunk

Switch(config-if)#switchport trunk allow vlan all

Switch(config-if)#exit

  1. 在路由器连接交换机的端口上去掉IP地址,使之成为二层接口。

Router>enable

Router#config terminal

Router(config)#interface fastethernet 0/0

Router(config-if)#no ip address

Router(config-if)#exit

  1. 在路由器上开启连接交换机的端口(no shtudwon),设置子接口IP地址,此IP地址将自动成为各VLAN的网关。

Router(config)#interface fastethernet 0/0

Router(config-if)#no shutdown

Router(config)#interface fastethernet 0/0.2

Router(config-subif)#encapsulation dot1Q 2

Router(config-subif)#ip address 192.168.2.1 255.255.255.0

Router(config-subif)#no shutdown

Router(config-subif)#exit

Router(config)#interface fastethernet 0/0.3

Router(config-subif)#encapsulation dot1q 3

Router(config-subif)#ip address 192.168.3.1 255.255.255.0

Router(config-subif)#no shutdown

Router(config-subif)#exit

Router(config)#interface fastethernet 0/0.4

Router(config-subif)#encapsulation dot1Q 4

Router(config-subif)#ip address 192.168.4.1 255.255.255.0

Router(config-subif)#no shutdown

Router(config-subif)#exit

OK,配置完成,现在可以在VLAN2上ping一下VLAN3、VLAN4,测试连通性。

PC>ipconfig /all

Physical Address................: 0001.9751.4CB5

IP Address......................: 192.168.2.2

Subnet Mask.....................: 255.255.255.0

Default Gateway.................: 192.168.2.1

DNS Servers.....................: 0.0.0.0

PC>ping 192.168.3.2

Pinging 192.168.3.2 with 32 bytes of data:

Reply from 192.168.3.2: bytes=32 time=13ms TTL=127

Reply from 192.168.3.2: bytes=32 time=18ms TTL=127

Reply from 192.168.3.2: bytes=32 time=8ms TTL=127

Reply from 192.168.3.2: bytes=32 time=15ms TTL=127

Ping statistics for 192.168.3.2:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 8ms, Maximum = 18ms, Average = 13ms

PC>ping 192.168.4.2

Pinging 192.168.4.2 with 32 bytes of data:

Reply from 192.168.4.2: bytes=32 time=11ms TTL=127

Reply from 192.168.4.2: bytes=32 time=15ms TTL=127

Reply from 192.168.4.2: bytes=32 time=16ms TTL=127

Reply from 192.168.4.2: bytes=32 time=18ms TTL=127

Ping statistics for 192.168.4.2:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 11ms, Maximum = 18ms, Average = 15ms

建立简单的VLAN通信的更多相关文章

  1. Linux下简单的socket通信实例

    Linux下简单的socket通信实例 If you spend too much time thinking about a thing, you’ll never get it done. —Br ...

  2. 跨Vlan通信:单臂路由,三层交换机

    实验涉及命令以及知识补充(涉及Vlan通过的以太网口需要设置为Trunk口) 单臂路由 父接口 no ip address :删除实现单臂路由接口的IP no shutdown 虚拟子接口 R2(co ...

  3. php简单实现socket通信

    socket通信的原理在这里就不说了,它的用途还是比较广泛的,我们可以使用socket来做一个API接口出来,也可以使用socket来实现两个程序之间的通信,我们来研究一下在php里面如何实现sock ...

  4. C#--简单的串口通信程序

    前几天做毕业设计,其中要用到串口和下位机进行通信,于是自己捣鼓了一个简单的串口通信程序. 在做通信之前要先弄一个SerialPort组件出来,当然也可以通过程序来创建.本次设计中采用的是拖的winfo ...

  5. php建立简单的用户留言系统

    php建立简单的用户留言系统 样例 addMsg.php--添加留言页面 doAction.php--响应添加留言页面 . viewMsg.php--显示留言页面 目录结构 addMsg.php--添 ...

  6. C#实现简单的串口通信

    前言 本着学习研究的态度,用c#语言实现简单的串口通信工具. 一.串口通信原理 串口通信 串口通信(Serial Communications)的概念非常简单,串口按位(bit)发送和接收字节.尽管比 ...

  7. Android简单实现Socket通信,client连接server后,server向client发送文字数据

    案例实现的是简单的Socket通信,当client(Androidclient)连接到指定server以后,server向client发送一句话文字信息(你能够拓展其他的了) 先看一下服务端程序的实现 ...

  8. Trunk 实现跨交换机 VLAN 通信

    当网络中有多台交换机时,位于不同交换机上的相同VLAN的主机之间时如何通信的呢?我们使用Trunk实现跨交换机VLAN通信.还有以太网通道的操作哦. 实验拓扑 两台交换机直连,每台下面再连接两台VPC ...

  9. 在不同网段使用 VLAN 通信 - SVI,单臂路由

    在 VLAN 这篇文章中知道,设置 VLAN 目的是隔离大型的广播域,将其分成很小的广播域,从而更好的管理.但也就带来了一些问题:如流量不能在不同的 VLAN 间通信. 而为了解决这个问题,可以采用如 ...

随机推荐

  1. [wikioi]线段树练习

    http://codevs.cn/problem/1080/ #include <vector> #include <iostream> #include <string ...

  2. ubuntu下安装pthread的manpages(man 手册) 在Ubuntu中查看STL帮助

    http://blog.csdn.net/leisure512/article/details/4881391 由于学习多线程编程,所以用到pthread,但是man的时候却发现没有pthread函数 ...

  3. chrome中tcmalloc的使用

    chrome中内存分配采用了第三方库tcmalloc,这个库主要提供给应用程序内存管理方面的优化,按资料说内存存取速度会从300ns降到50ns.更具体的关于这个tcmalloc的信息大家可以查网上的 ...

  4. shell编程基础(5)---循环指令

    while类型的循环 while类型的循环是不定循环的一种,每一次循环都会验证给出的循环条件,判断是否要进行下一次循环.linux中while循环的写法和c语言中很想,但是条件给出的方式有些区别. 首 ...

  5. 转 Android的消息处理机制(图+源码分析)——Looper,Handler,Message

    作为一个大三的预备程序员,我学习android的一大乐趣是可以通过源码学习google大牛们的设计思想.android源码中包含了大量的设计模式,除此以外,android sdk还精心为我们设计了各种 ...

  6. Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.

    在部署的时候出现Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If the server ...

  7. Dozer应用——类之间值的映射

    1. Mappings via Annotation public class SourceBean { private Long id; private String name; @Mapping( ...

  8. Codeforces Round #239 (Div. 2)

    做了三个题,先贴一下代码...终于涨分了 A. Line to Cashier 水题 #include <iostream> #include <cstdio> #includ ...

  9. BootStrap基本样式

    文本对齐风格:.text-left:左对齐.text-center:居中对齐.text-right:右对齐.text-justify:两端对齐 取消列表符号:.list-unstyled内联列表:.l ...

  10. 设置mysql的interactive_timeout和wait_timeout的值

    1,为什么要重新设置这两个变量的值? 因为如果数据库默认这两个变量的值是8小时(即28800秒)如果在8小时之内没有连接到数据库,等下次再连的时候就会抛连接超时,或连接关闭这样的异 常,但是多连接几次 ...