设为首页收藏本站language 语言切换
查看: 2681|回复: 8
收起左侧

[分享] CCNA vlan间实现互访

[复制链接]
发表于 2012-11-17 15:28:47 | 显示全部楼层 |阅读模式
Switch#conf t
    Enter configuration commands, one per line. End with CNTL/Z.
    Switch(config)#vla 2
    Switch(config-vlan)#int f0/1
    Switch(config-if)#switchport mode access
    Switch(config-if)#switchport access vlan 1
    Switch(config-if)#int f0/2
    Switch(config-if)#switchport mode access
    Switch(config-if)#switchport access vlan 2
    Switch(config-if)#exit
    Switch(config)#ip routing   '开启路由功能
    Switch(config)#int vlan 1
    Switch(config-if)#no shutdown
    %LINK-5-CHANGED: Interface Vlan1, changed state to up
    %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
    Switch(config-if)#ip address 192.168.1.254 255.255.255.0
    Switch(config-if)#int vlan 2
    %LINK-5-CHANGED: Interface Vlan2, changed state to up
    %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to upSwitch(config-if)#no shut
    Switch(config-if)#no shutdown
    Switch(config-if)#ip address 192.168.2.254 255.255.255.0
    Switch(config-if)#end
    %SYS-5-CONFIG_I: Configured from console by console
    Switch#sh ip rou
    Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    * - candidate default, U - per-user static route, o - ODR
    P - periodic downloaded static route
    Gateway of last resort is not set
    C    192.168.1.0/24 is directly connected, Vlan1
    C    192.168.2.0/24 is directly connected, Vlan2
    Switch#
    不同VLAN的主机ping测试通讯:
    Packet Tracer PC Command Line 1.0
    PC>ipconfig /all
    Physical Address……: 0030.A399.6C5B
    IP Address……: 192.168.1.1
    Subnet Mask……: 255.255.255.0
    Default Gateway……: 192.168.1.254
    DNS Servers……: 0.0.0.0
    PC>ping 192.168.2.1
    Pinging 192.168.2.1 with 32 bytes of data:
    Reply from 192.168.2.1: bytes=32 time=63ms TTL=127
    Reply from 192.168.2.1: bytes=32 time=63ms TTL=127
    Reply from 192.168.2.1: bytes=32 time=62ms TTL=127
    Reply from 192.168.2.1: bytes=32 time=63ms TTL=127
    Ping statistics for 192.168.2.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
    Minimum = 62ms, Maximum = 63ms, Average = 62ms
    PC>
    不同VLAN通讯需要第三层的路由器,没有三层交换机时,可以用一个路由器加一个交换机做单臂路由:
路由器的设置:
    Router>en
    Router#conf t
    Enter configuration commands, one per line. End with CNTL/Z.
    Routerconfig#int f0/0
    Routerconfig-if#no shut
    %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
    Routerconfig-if#int f0/0.1
    %LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed state to upRouterconfig-subif#en
    Routerconfig-subif#encapsulation dot1Q 1 native
    Routerconfig-subif#ip address 192.168.1.254 255.255.255.0
    Routerconfig-subif#int f0/0.2
    %LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to upRouterconfig-subif#en
    Routerconfig-subif#encapsulation dot1Q 2
    Routerconfig-subif#ip address 192.168.2.254 255.255.255.0
    Routerconfig-subif#end
    %SYS-5-CONFIG_I: Configured from console by console
    Router#
    交换机的配置:
    Switch>en
    Switch#conf t
    Enter configuration commands, one per line. End with CNTL/Z.
    Switchconfig#vla 2
    Switchconfig-vlan#int f0/2
    Switchconfig-if#switchport access vlan 2
    Switchconfig-if#switchport mode access
    Switchconfig-if#exit
    Switchconfig#int f0/1
    Switchconfig-if#switchport mode access
    Switchconfig-if#switchport access vlan 1
    Switchconfig-if#end
    %SYS-5-CONFIG_I: Configured from console by console
    Switch#sh vlan br
    VLAN Name                             Status    Ports
    ---- -------------------------------- --------- -------------------------------
    1    default                          active    Fa0/1, Fa0/3, Fa0/4, Fa0/5
    Fa0/6, Fa0/7, Fa0/8, Fa0/9
    Fa0/10, Fa0/11, Fa0/12, Fa0/13
    Fa0/14, Fa0/15, Fa0/16, Fa0/17
    Fa0/18, Fa0/19, Fa0/20, Fa0/21
    Fa0/22, Fa0/23, Fa0/24
    2    VLAN0002                         active    Fa0/2
    1002 fddi-default                     active
    1003 token-ring-default               active
    1004 fddinet-default                  active
    1005 trnet-default                    active
    Switch#conf t
    Enter configuration commands, one per line. End with CNTL/Z.
    Switchconfig#int f0/24
    Switchconfig-if#switchport mode trunk
    Switchconfig-if#
    %LINK-5-CHANGED: Interface FastEthernet0/24, changed state to up
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up
    PCping测试
    PC>ipconfig /all
    Physical Address…… 00E0.8FE0.8D94
    IP Address…… 192.168.1.1
    Subnet Mask…… 255.255.255.0
    Default Gateway…… 192.168.1.254
    DNS Servers…… 0.0.0.0
    PC>ping 192.168.2.1
    Pinging 192.168.2.1 with 32 bytes of data:
    Reply from 192.168.2.1: bytes=32 time=125ms TTL=127
    Reply from 192.168.2.1: bytes=32 time=125ms TTL=127
    Reply from 192.168.2.1: bytes=32 time=125ms TTL=127
    Reply from 192.168.2.1: bytes=32 time=125ms TTL=127
    Ping statistics for 192.168.2.1:
    Packets: Sent = 4, Received = 4, Lost = 0 0% loss),
    Approximate round trip times in milli-seconds:
    Minimum = 125ms, Maximum = 125ms, Average = 125ms
    PC>

点评

辛苦  发表于 2012-12-4 22:20
发表于 2012-11-17 16:27:12 | 显示全部楼层
辛苦了
沙发 2012-11-17 16:27:12 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2012-12-3 22:39:54 | 显示全部楼层
板凳 2012-12-3 22:39:54 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2012-12-4 20:53:32 | 显示全部楼层
阿斯蒂芬阿斯顿飞
地板 2012-12-4 20:53:32 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2012-12-4 21:15:02 | 显示全部楼层
膜拜神贴,后面的请保持队形~
5# 2012-12-4 21:15:02 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2012-12-21 12:17:15 | 显示全部楼层
6# 2012-12-21 12:17:15 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2012-12-21 12:23:03 | 显示全部楼层
7# 2012-12-21 12:23:03 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2013-9-10 15:20:57 | 显示全部楼层
8# 2013-9-10 15:20:57 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-2-27 18:14 , Processed in 0.060432 second(s), 24 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表