您的位置:首页 > 其它

路由器单臂路由配置------配置子接口是配置单臂路由的关键

2013-11-24 01:28 323 查看
拓扑图如下:



配置交换机S1

Switch>en

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#host S1

S1(config)#vlan 20

S1(config-vlan)#vlan 30

S1(config-vlan)#exit

S1(config)#int fa0/2

S1(config-if)#switchport mode access

S1(config-if)#switchport access vlan 20

S1(config-if)#exit

S1(config)#int fa0/3

S1(config-if)#switchport mode access

S1(config-if)#switchport access vlan 30

S1(config-if)#exit

S1(config)#int fa0/1

S1(config-if)#switchport mode access

S1(config-if)#switchport mode trunk

S1(config-if)#switchport trunk allowed vlan all
!--- Trunk端口允许所有VLAN的发送和接口传输,这也是默认状态,该条指令可选。

S1(config-if)#end

S1#show vlan

VLAN Name Status Ports

---- -------------------------------- --------- -------------------------------

1 default active 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, Gig1/1, Gig1/2

20 VLAN0020 active Fa0/2

30 VLAN0030 active Fa0/3

1002 fddi-default act/unsup

1003 token-ring-default act/unsup

1004 fddinet-default act/unsup

1005 trnet-default act/unsup

VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2

---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------

1 enet 100001 1500 - - - - - 0 0

20 enet 100020 1500 - - - - - 0 0

30 enet 100030 1500 - - - - - 0 0

1002 fddi 101002 1500 - - - - - 0 0

1003 tr 101003 1500 - - - - - 0 0

1004 fdnet 101004 1500 - - - ieee - 0 0

1005 trnet 101005 1500 - - - ibm - 0 0

Remote SPAN VLANs

------------------------------------------------------------------------------

Primary Secondary Type Ports

------- --------- ----------------- ------------------------------------------

S1#

配置路由器R1

Router>en

Router#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#host R1

R1(config)#int fa0/0

R1(config-if)#no shut

R1(config-if)#

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R1(config-if)#exit

R1(config)#int fa0/0.1 !--- 配置子接口是配置单臂路由的关键,它是一个逻辑接口,实际并不存在的物理接口,其功能却和物理接口一样。

R1(config-subif)#

%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed state to up

R1(config-subif)#encapsulation dot1q 20 !--- 配置子接口使用的802.1Q协议,最后面的20是VLAN号

R1(config-subif)#ip add 192.168.1.1 255.255.255.0

R1(config-subif)#exit

R1(config)#int fa0/0.2

R1(config-subif)#

%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to up

R1(config-subif)#encapsulation dot1q 30

R1(config-subif)#ip add 192.168.2.1 255.255.255.0

R1(config-subif)#end

R1#

%SYS-5-CONFIG_I: Configured from console by console

R1#show ip route

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, FastEthernet0/0.1

C 192.168.2.0/24 is directly connected, FastEthernet0/0.2

R1#

测试单臂路由配置:

PC>ipconfig

FastEthernet0 Connection:(default port)

Link-local IPv6 Address.........: FE80::202:4AFF:FE14:89CB

IP Address......................: 192.168.1.2

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

Default Gateway.................: 192.168.1.1

PC>ping 192.168.2.2

Pinging 192.168.2.2 with 32 bytes of data:

Request timed out.

Reply from 192.168.2.2: bytes=32 time=0ms TTL=127

Reply from 192.168.2.2: bytes=32 time=0ms TTL=127

Reply from 192.168.2.2: bytes=32 time=0ms TTL=127

Ping statistics for 192.168.2.2:

Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 0ms, Average = 0ms

PC>

测试结构表明配置完全正确
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: