用三层交换机构建小型网络

 

启用(交换机的路由功能)

 

 

Switch 0 的配置:

 

Press RETURN to get started!

 

 

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch>enable

Switch#configure terminal

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

Switch(config)#interface fastEthernet 0/1

Switch(config-if)#no switchport

 

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

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch(config-if)#ip address 1.1.1.1 255.0.0.0

Switch(config-if)#no shutdown

Switch(config-if)#exit

Switch(config)#interface fastEthernet 0/2

Switch(config-if)#no switchport

 

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

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch(config-if)#

Switch(config-if)#ip address 3.3.3.1 255.0.0.0

Switch(config-if)#no shutdown

Switch(config-if)#exit

Switch(config)#ip rout?

route  routing 

Switch(config)#ip routing

Switch(config)#ip route 2.0.0.0 255.0.0.0 ?

  A.B.C.D          Forwarding router's address

  Ethernet         IEEE 802.3

  FastEthernet     FastEthernet IEEE 802.3

  GigabitEthernet  GigabitEthernet IEEE 802.3z

  Loopback         Loopback interface

  Null             Null interface

  Serial           Serial

  Vlan             Catalyst Vlans

Switch(config)#ip route 2.0.0.0 255.0.0.0 fastEthernet 0/2

Switch(config)#exit

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

Switch#show ip rout

Switch#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    1.0.0.0/8 is directly connected, FastEthernet0/1

S    2.0.0.0/8 is directly connected, FastEthernet0/2

C    3.0.0.0/8 is directly connected, FastEthernet0/2

Switch#ping 2.2.2.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 62/62/63 ms

 

Switch#show r

Switch#show running-config

Building configuration...

 

Current configuration : 1181 bytes

!

version 12.2

no service password-encryption

!

hostname Switch

!

!

ip routing

!

!

!

!

ip ssh version 1

!

port-channel load-balance src-mac

!

interface FastEthernet0/1

 no switchport

 ip address 1.1.1.1 255.0.0.0

 duplex auto

 speed auto

!

interface FastEthernet0/2

 no switchport

 ip address 3.3.3.1 255.0.0.0

 duplex auto

 speed auto

!

interface FastEthernet0/3

!

interface FastEthernet0/4

!

interface FastEthernet0/5

!

interface FastEthernet0/6

!

interface FastEthernet0/7

!

interface FastEthernet0/8

!

interface FastEthernet0/9

!

interface FastEthernet0/10

!

interface FastEthernet0/11

!

interface FastEthernet0/12

!

interface FastEthernet0/13

!

interface FastEthernet0/14

!

interface FastEthernet0/15

!

interface FastEthernet0/16

!

interface FastEthernet0/17

!

interface FastEthernet0/18

!

interface FastEthernet0/19

!

interface FastEthernet0/20

!

interface FastEthernet0/21

!

interface FastEthernet0/22

!

interface FastEthernet0/23

!

interface FastEthernet0/24

!

interface GigabitEthernet0/1

!

interface GigabitEthernet0/2

!

interface Vlan1

 no ip address

 shutdown

!

ip classless

ip route 2.0.0.0 255.0.0.0 FastEthernet0/2

!

!

!

!

!

line con 0

line vty 0 4

 login

!

!

end

 

 

Switch#

 

 

 

Switch1 配置:

 

Press RETURN to get started!

 

 

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch>enable

Switch#configure terminal

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

Switch(config)#interface fastEthernet 0/1

Switch(config-if)#no switchport

 

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

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch(config-if)#

Switch(config-if)#ip address 2.2.2.1 255.0.0.0

Switch(config-if)#no shutdown

Switch(config-if)#exit

Switch(config)#interface fastEthernet 0/2

Switch(config-if)#no switchport

 

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

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch(config-if)#

Switch(config-if)#ip address 3.3.3.2 255.0.0.0

Switch(config-if)#no shutdown

Switch(config-if)#exit

Switch(config)#ip routing

Switch(config)#ip route 1.0.0.0 255.0.0.0 ?

  A.B.C.D          Forwarding router's address

  Ethernet         IEEE 802.3

  FastEthernet     FastEthernet IEEE 802.3

  GigabitEthernet  GigabitEthernet IEEE 802.3z

  Loopback         Loopback interface

  Null             Null interface

  Serial           Serial

  Vlan             Catalyst Vlans

Switch(config)#ip route 1.0.0.0 255.0.0.0 ?

  A.B.C.D          Forwarding router's address

  Ethernet         IEEE 802.3

  FastEthernet     FastEthernet IEEE 802.3

  GigabitEthernet  GigabitEthernet IEEE 802.3z

  Loopback         Loopback interface

  Null             Null interface

  Serial           Serial

  Vlan             Catalyst Vlans

Switch(config)#ip route 1.0.0.0 255.0.0.0 fastEthernet 0/2

Switch(config)#no shut

Switch(config)#exit

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

Switch#show ip rout

Switch#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

 

S    1.0.0.0/8 is directly connected, FastEthernet0/2

C    2.0.0.0/8 is directly connected, FastEthernet0/1

C    3.0.0.0/8 is directly connected, FastEthernet0/2

Switch#ping 1.1.1.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 62/62/63 ms

 

Switch#show int

Switch#show interfaces f

Switch#show interfaces fastEthernet 0/1

FastEthernet0/1 is up, line protocol is up (connected)

  Hardware is Lance, address is 0090.2b2c.9e01 (bia 0090.2b2c.9e01)

  MTU 1500 bytes, BW 100000 Kbit, DLY 1000 usec,

     reliability 255/255, txload 1/255, rxload 1/255

  Encapsulation ARPA, loopback not set

  Keepalive set (10 sec)

  Full-duplex, 100Mb/s

  input flow-control is off, output flow-control is off

  ARP type: ARPA, ARP Timeout 04:00:00

  Last input 00:00:08, output 00:00:05, output hang never

  Last clearing of "show interface" counters never

  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0

  Queueing strategy: fifo

  Output queue :0/40 (size/max)

  5 minute input rate 0 bits/sec, 0 packets/sec

  5 minute output rate 0 bits/sec, 0 packets/sec

     956 packets input, 193351 bytes, 0 no buffer

     Received 956 broadcasts, 0 runts, 0 giants, 0 throttles

     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort

     0 watchdog, 0 multicast, 0 pause input

     0 input packets with dribble condition detected

     2357 packets output, 263570 bytes, 0 underruns

     0 output errors, 0 collisions, 10 interface resets

     0 babbles, 0 late collision, 0 deferred

     0 lost carrier, 0 no carrier

     0 output buffer failures, 0 output buffers swapped out

Switch#show r

Switch#show running-config

Building configuration...

 

Current configuration : 1181 bytes

!

version 12.2

no service password-encryption

!

hostname Switch

!

!

ip routing

!

!

!

!

ip ssh version 1

!

port-channel load-balance src-mac

!

interface FastEthernet0/1

 no switchport

 ip address 2.2.2.1 255.0.0.0

 duplex auto

 speed auto

!

interface FastEthernet0/2

 no switchport

 ip address 3.3.3.2 255.0.0.0

 duplex auto

 speed auto

!

interface FastEthernet0/3

!

interface FastEthernet0/4

!

interface FastEthernet0/5

!

interface FastEthernet0/6

!

interface FastEthernet0/7

!

interface FastEthernet0/8

!

interface FastEthernet0/9

!

interface FastEthernet0/10

!

interface FastEthernet0/11

!

interface FastEthernet0/12

!

interface FastEthernet0/13

!

interface FastEthernet0/14

!

interface FastEthernet0/15

!

interface FastEthernet0/16

!

interface FastEthernet0/17

!

interface FastEthernet0/18

!

interface FastEthernet0/19

!

interface FastEthernet0/20

!

interface FastEthernet0/21

!

interface FastEthernet0/22

!

interface FastEthernet0/23

!

interface FastEthernet0/24

!

interface GigabitEthernet0/1

!

interface GigabitEthernet0/2

!

interface Vlan1

 no ip address

 shutdown

!

ip classless

ip route 1.0.0.0 255.0.0.0 FastEthernet0/2

!

!

!

!

!

line con 0

line vty 0 4

 login

!

!

end

 

 

Switch#

 

主机 pc0 ping   pc1 :

 

Packet Tracer PC Command Line 1.0
PC>ping 2.2.2.2

 

Pinging 2.2.2.2 with 32 bytes of data:

 

Reply from 2.2.2.2: bytes=32 time=80ms TTL=126
Reply from 2.2.2.2: bytes=32 time=94ms TTL=126
Reply from 2.2.2.2: bytes=32 time=93ms TTL=126
Reply from 2.2.2.2: bytes=32 time=93ms TTL=126

 

Ping statistics for 2.2.2.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 80ms, Maximum = 94ms, Average = 90ms

 

PC>tracert 2.2.2.2

 

Tracing route to 2.2.2.2 over a maximum of 30 hops:

 

  1   32 ms     31 ms     31 ms     1.1.1.1
  2   63 ms     63 ms     63 ms     3.3.3.2
  3   94 ms     78 ms     93 ms     2.2.2.2

 

Trace complete.

 

PC>

 

 

 

注意:在三层交换机上启动“路由”功能,应该有静态路由。