静态路由在三层交换机上的应用_职场
 
静态路由的应用
 
Switch 0 的配置:
 
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface f0/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 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 2.2.2.1 255.0.0.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#ip route 4.0.0.0 255.0.0.0 f
Switch(config)#ip route 4.0.0.0 255.0.0.0 f?
FastEthernet 
Switch(config)#ip route 4.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 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
C    2.0.0.0/8 is directly connected, FastEthernet0/2
S    4.0.0.0/8 is directly connected, FastEthernet0/2
Switch#
Switch#show ?
  access-lists       List access lists
  adjacency          Adjacent nodes
  arp                Arp table
  cdp                CDP information
  clock              Display the system clock
  controllers        Interface controllers status
  crypto             Encryption module
  debugging          State of each debugging option
  dhcp               Dynamic Host Configuration Protocol status
  etherchannel       EtherChannel information
  flash:             display information about flash: file system
  frame-relay        Frame-Relay information
  history            Display the session command history
  hosts              IP domain-name, lookup style, nameservers, and host table
  interfaces         Interface status and configuration
  ip                 IP information
  ipv6               IPv6 information
  mac-address-table  MAC forwarding table
  ospf               For OSPF debug only
  ospfv3             For OSPFv3 debug only
  processes          Active process statistics
  protocols          Active network routing protocols
  running-config     Current operating configuration
  sessions           Information about Telnet connections
  spanning-tree      Spanning tree topology
  ssh                Status of SSH server connections
  startup-config     Contents of startup configuration
  tcp                Status of TCP connections
  terminal           Display terminal configuration parameters
  users              Display information about terminal lines
  version            System hardware and software status
  vlan               VTP VLAN status
  vtp                Configure VLAN database
Switch#show ip ?
  access-lists  List access lists
  arp           IP ARP table
  cef           Cisco Express Forwarding
  dhcp          Show items in the DHCP database
  eigrp         IP-EIGRP show commands
  interface     IP interface status and configuration
  nat           IP NAT information
  ospf          OSPF information
  protocols     IP routing protocol process parameters and statistics
  rip           IP RIP show commands
  route         IP routing table
  ssh           Information on SSH
Switch#show ip interface ?
  Ethernet         IEEE 802.3
  FastEthernet     FastEthernet IEEE 802.3
  GigabitEthernet  GigabitEthernet IEEE 802.3z
  Loopback         Loopback interface
  Serial           Serial
  Vlan             Catalyst Vlans
  brief            Brief summary of IP status and configuration
  <cr>
Switch#show ip interface fastEthernet 0/1
FastEthernet0/1 is up, line protocol is up
  Internet protocol processing disabled
Switch#show ip interface fastEthernet 0/2
FastEthernet0/2 is up, line protocol is up
  Internet protocol processing disabled
Switch#show running-config
Building configuration...
 
Current configurat
!
hostname Switch ion : 1168 bytes
!
version 12.2
no service password-encryption
!
!
!
!
!
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 2.2.2.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 4.0.0.0 255.0.0.0 FastEthernet0/2
!
!
!
!
!
line con 0
line vty 0 4
 login
!
!
end
 
 
Switch#
 
 
 
 
 
 
 
 
 
Switch 1的配置:
 
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 upSwitch(config-if)#ip add
Switch(config-if)#ip address 2.2.2.2 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 route 1.0.0.0 255.0.0.0 fastEthernet 0/1
Switch(config)#ip route 4.0.0.0 255.0.0.0 fastEthernet 0/2
Switch(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
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 80 percent (4/5), round-trip min/avg/max = 47/59/63 ms
 
Switch#ping 4.4.4.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 47/59/63 ms
 
Switch#ping 2.2.2.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/31/32 ms
 
Switch#ping 3.3.3.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 15/28/32 ms
 
Switch#show ip rou
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/1
C    2.0.0.0/8 is directly connected, FastEthernet0/1
C    3.0.0.0/8 is directly connected, FastEthernet0/2
S    4.0.0.0/8 is directly connected, FastEthernet0/2
Switch#
 
 
 
 
 
 
Switch 2 的配置:
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
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)#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 4.4.4.1 255.0.0.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#ip route 1.0.0.0 255.0.0.0 fastEthernet 0/2
Switch(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
Switch#ping 4.4.4.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/31/32 ms
 
Switch#ping 3.3.3.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/31/32 ms
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    3.0.0.0/8 is directly connected, FastEthernet0/2
C    4.0.0.0/8 is directly connected, FastEthernet0/1