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

转载于:https://www.cnblogs.com/phoenixzq/p/3430125.html

建立简单的VLAN通信相关推荐

  1. 【计算机网络】思科实验(4):综合实验作业之办公室的跨VLAN通信

    系列文章目录 [计算机网络]思科实验(1):交换机的VLAN划分 [计算机网络]思科实验(2):交换机间的VLAN通信 [计算机网络]思科实验(3):使用三层交换机实现跨VLAN间的通信 [计算机网络 ...

  2. 简单的socket通信实现

    一.什么是socket网络通信? socket也称作"套接字",描述了计算机的IP地址和端口,运行在计算机中的程序之间采用socket进行数据通信.通信的两端都有socket,它是 ...

  3. Spring和WebSocket整合并建立简单的Web聊天室

    Spring和WebSocket整合并建立简单的Web聊天室 官方主页 Spring WebSocket 一.概述 WebSocket 是一种网络通信协议.RFC6455 定义了它的通信标准. Web ...

  4. VLAN,简单配置vlan

    VLAN 在交换机中工作 分割广播域 物理分割--------子网掩码划分 逻辑分割---------VLAN划分 VLAN的优势 控制广播 增强网络安全性 简化网络管理 VLAN的种类 静态VLAN ...

  5. 【计算机网络】思科实验(2):交换机间的VLAN通信

    系列文章目录 [计算机网络]思科实验(1):交换机的VLAN划分 [计算机网络]思科实验(2):交换机间的VLAN通信 [计算机网络]思科实验(3):使用三层交换机实现跨VLAN间的通信 [计算机网络 ...

  6. 使用vb.net开发简单的socket通信

    使用vb.net开发简单的socket通信(环境是visual stdio 2019) 说明 参考文章 实现功能 效果展示 代码 服务端 客户端 总结 说明 之前用vb6编程时都是用的winsock控 ...

  7. 跨vlan通信之vlanif配置-华为ensp

    跨vlan通信的手段之一:vlanif 定义:VLANIF(Virtual Local Area Network Interface),是华为交换机的一个配置项,应用于三层交换机.这是一种逻辑接口,物 ...

  8. 配置Trunk实现相同Vlan通信

    路由交换技术,配置Trunk实现相同Vlan通信! 转载于:https://blog.51cto.com/yuanliujun/362657

  9. java 通信 教程_Java实现简单的socket通信教程

    今天学习了一下java如何实现socket通信,感觉难点反而是在io上,因为java对socket封装已经很完善了. 今天代码花了整个晚上调试,主要原因是io的flush问题和命令行下如何运行具有pa ...

最新文章

  1. 图解完整模式安装windows server 2008企业版[为企业部署Windows Server 2008系列四]
  2. python语言实例-Python与其他语言比较实例
  3. pov-inc_yourself劳自己-懒惰的设计师的POV和一些Figma
  4. 8086算术移位指令SAL和SAR
  5. ASP.NET MVC下的四种验证编程方式[续篇]
  6. java 以太坊 智能合约_web3j教程:java使用web3j开发以太坊智能合约交易
  7. 常见的几种索引扫描类型
  8. 此C语言功能---A
  9. pytorch: MaxUnpool2d 与 Upsampling
  10. 观察者模式 - Observer
  11. 求问模式达人,静态类可否代替单件?
  12. 《Linux内核设计与实现》读书笔记 第一章 Linux内核简介
  13. AutoCAD Civil 3D 2012正式发布
  14. python识别图片指定位置文字_python 识别图片中的文字信息方法
  15. 百度地图API的两种加载方式
  16. DRM驱动(五)之drm_atomic_state
  17. 软件测试工程师应届生工资,软件测试工程师薪水平均是什么水平?前景发展如何?...
  18. 洗地机哪个品牌好用,洗地机十大品牌分享
  19. 海量数据的存储和访问解决方案
  20. Failed to load response dataNo data found for resource with given identifier

热门文章

  1. 思源EMLOG文章页网址跳转插件V1.1
  2. 3款动态网页时间时钟HTML5源码
  3. 关于大型网站技术演进的思考(六)--存储的瓶颈(6)
  4. Node.js 连接 MySQL 并进行数据库操作 –node.js 开发指南
  5. 10个优秀视差滚动插件
  6. Mysql之inner join,left join,right join详解
  7. Python_多元回归(一元回归)
  8. Linux开启路由转发功能
  9. Http压力测试之ab
  10. 数据结构---function