建立简单的VLAN通信
http://minitoo.blog.51cto.com/4201040/786011(转载)
在路由器上做单臂路由实现VLAN间路由,也就是设置子接口和封装协议。
实现环境如下图:

- 在交换机上建立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
- 在交换机连接路由器的接口上配置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
- 在路由器连接交换机的端口上去掉IP地址,使之成为二层接口。
Router>enable
Router#config terminal
Router(config)#interface fastethernet 0/0
Router(config-if)#no ip address
Router(config-if)#exit
- 在路由器上开启连接交换机的端口(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通信的更多相关文章
- Linux下简单的socket通信实例
Linux下简单的socket通信实例 If you spend too much time thinking about a thing, you’ll never get it done. —Br ...
- 跨Vlan通信:单臂路由,三层交换机
实验涉及命令以及知识补充(涉及Vlan通过的以太网口需要设置为Trunk口) 单臂路由 父接口 no ip address :删除实现单臂路由接口的IP no shutdown 虚拟子接口 R2(co ...
- php简单实现socket通信
socket通信的原理在这里就不说了,它的用途还是比较广泛的,我们可以使用socket来做一个API接口出来,也可以使用socket来实现两个程序之间的通信,我们来研究一下在php里面如何实现sock ...
- C#--简单的串口通信程序
前几天做毕业设计,其中要用到串口和下位机进行通信,于是自己捣鼓了一个简单的串口通信程序. 在做通信之前要先弄一个SerialPort组件出来,当然也可以通过程序来创建.本次设计中采用的是拖的winfo ...
- php建立简单的用户留言系统
php建立简单的用户留言系统 样例 addMsg.php--添加留言页面 doAction.php--响应添加留言页面 . viewMsg.php--显示留言页面 目录结构 addMsg.php--添 ...
- C#实现简单的串口通信
前言 本着学习研究的态度,用c#语言实现简单的串口通信工具. 一.串口通信原理 串口通信 串口通信(Serial Communications)的概念非常简单,串口按位(bit)发送和接收字节.尽管比 ...
- Android简单实现Socket通信,client连接server后,server向client发送文字数据
案例实现的是简单的Socket通信,当client(Androidclient)连接到指定server以后,server向client发送一句话文字信息(你能够拓展其他的了) 先看一下服务端程序的实现 ...
- Trunk 实现跨交换机 VLAN 通信
当网络中有多台交换机时,位于不同交换机上的相同VLAN的主机之间时如何通信的呢?我们使用Trunk实现跨交换机VLAN通信.还有以太网通道的操作哦. 实验拓扑 两台交换机直连,每台下面再连接两台VPC ...
- 在不同网段使用 VLAN 通信 - SVI,单臂路由
在 VLAN 这篇文章中知道,设置 VLAN 目的是隔离大型的广播域,将其分成很小的广播域,从而更好的管理.但也就带来了一些问题:如流量不能在不同的 VLAN 间通信. 而为了解决这个问题,可以采用如 ...
随机推荐
- go学习资料及优秀博文
相关书籍: Go Web编程 http://blog.csdn.net/broadview2006/article/details/8875097 优秀博文: 系统编程语言明日之星—Go(http:/ ...
- Unigui有用的网址
http://www.cnblogs.com/ChinaEHR/tag/Delphi/
- WCF入门(十二)---WCF异常处理
WCF服务开发者可能会遇到需要以适当的方式向客户端报告一些不可预见的错误.这样的错误,称为异常,通常是通过使用try/catch块来处理,但同样,这是非常具体的技术. 由于客户端的关注领域不是关于如何 ...
- Failed to allocate memory: 8
Failed to allocate memory: 8This application has requested the Runtime to terminate it in an unusual ...
- 区分int a() 和 int a
事因 #include <iostream> using namespace std; struct A { A(int) {} A() {} void fun() {}; }; int ...
- SPOJ 1108 Card Trick 暴力模拟
解释一下样例,因为我觉得这个题意表述的不是很清楚.以第二组样例为例. 牌序为:3 1 4 5 2 第一轮:把 3 放到末尾:1 4 5 2 3,最顶上的牌是1,把1拿走.剩余 4 5 2 3 第二轮: ...
- mysql 行列动态转换(列联表,交叉表)
mysql 行列动态转换(列联表,交叉表) (1)动态,适用于列不确定情况 create table table_name( id int primary key, col1 char(2), col ...
- gulp browser-sync自动刷新插件
很久没弄gulp了,都快忘了,今天又来温习下browser-sync 自动刷新插件,在安装的时候出现以下提示: $ npm install browser-sync --save-dev> ws ...
- 转:表单中Readonly和Disabled的区别(HTML中使用javascript解除禁止input输入框代)
转:表单中Readonly和Disabled的区别 参考资料: disabled和readonly区别: 参考博文1地址:http://blog.csdn.net/symgdwyh/article/d ...
- std::ofstream由二进制流写文件的问题
从MPQ包中读取二进制流出来然后文件写到硬盘. DWORD size = SFileGetSize(hFile); char* buffer = new char[size]; std::ofstre ...