Cisco路由交换试题小测验

首页 / 编程代码 / 正文

实验一 路由器的基本配置
图片1.png

1.直接进入pc中进行ip地址和网关的设置
2.3 Router>enable
Router#conf t
Router(config)#hostname R1
R1(config)#interface g0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
4.R1>enable
R1#conf t
R1(config)#enable password cisco1
R1(config)#enable secret cisco1
5.R1(config)#line console 0
R1(config-line)#password cisco2
R1(config-line)#login
R1(config-line)#exit
6.R1(config)#line vty 0 4
R1(config-line)#password cisco3
R1(config-line)#login
R1(config-line)#exit
7.R1(config)#interface loopback 0
R1(config-if)#ip address 10.0.0.1 255.255.255.0
R1(config-if)#exit
8.R1(config)#banner motd ‘welcome to hnuahe.’
R1(config)#exit
9.R1(config)#service ?
R1(config)#service password-encryption
R1(config)#exit
R1#copy running-config startup-config
R1#
实验二 静态路由配置

//端口激活 no shutdown

                                  //同步时钟设置
                                             R1(config)#int f0/0

R1(config-if)#clock rate 64000
直连静态路由设置
R1
R1(config)#ip route 192.168.2.0 255.255.255.0 s2/0
R1(config)#ip route 172.16.0.0 255.255.255.0 s2/0
R1(config)#ip route 172.16.1.0 255.255.255.0 s2/0
R2
R2(config)#ip route 192.168.0.0 255.255.255.0 s2/0
R2(config)#ip route 172.16.1.0 255.255.255.0 s3/0
R3
R3(config)#ip route 192.168.0.0 255.255.255.0 s2/0
R3(config)#ip route 192.168.1.0 255.255.255.0 s2/0
R3(config)#ip route 192.168.2.0 255.255.255.0 s2/0
下一跳静态路由设置
R1
R1(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.1
R1(config)#ip route 172.16.0.0 255.255.255.0 192.168.1.1
R1(config)#ip route 172.16.1.0 255.255.255.0 192.168.1.1
R2
R2(config)#ip route 192.168.0.0 255.255.255.0 192.168.1.2
R2(config)#ip route 172.16.1.0 255.255.255.0 172.16.0.2
R3
R3(config)#ip route 192.168.0.0 255.255.255.0 172.16.0.1
R3(config)#ip route 192.168.1.0 255.255.255.0 172.16.0.1
R3(config)#ip route 192.168.2.0 255.255.255.0 172.16.0.1
默认路由配置
R3(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1
R3(config)#IP route 0.0.0.0 0.0.0.0 172.16.2.1
浮动路由设置
R1
R1(config)#int s3/0
R1(config-if)#no shut
R1(config-if)#cl rate 64000
R1(config-if)#ip add 172.16.2.1 255.255.255.0
R3
R3(config)#int s3/0
R3(config-if)#no shut
R3(config-if)#ip add 172.16.2.2 255.255.255.0
R1
R1(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.1
R1(config)#ip route 172.16.0.0 255.255.255.0 192.168.1.1
R1(config)#ip route 172.16.1.0 255.255.255.0 192.168.1.1
R1(config)#ip route 172.16.1.0 255.255.255.0 172.16.2.2
R1(config)#ip route 172.16.1.0 255.255.255.0 172.16.2.2 5
R3
R3(config)#ip route 192.168.0.0 255.255.255.0 172.16.0.1
R3(config)#ip route 192.168.1.0 255.255.255.0 172.16.0.1
R3(config)#ip route 192.168.2.0 255.255.255.0 172.16.0.1
R3(config)#ip route 192.168.0.0 255.255.255.0 172.16.2.1 5
R2
R2(config)#int s3/0
R2(config-if)#shut或no shut
实验三 动态路由RIPv2配置

R1(config)#route rip
R1(config-router)#ver 2
R1(config-router)#network 192.168.0.0
R1(config-router)#network 192.168.1.0
R1(config-router)#exit
R1(config)#ip route 0.0.0.0 0.0.0.0 202.196.133.254
R1(config)#route rip
R1(config-router)#default-information originate
R1(config-router)#no auto-summary
R1(config-router)#passive-interface f0/0

   R2(config)#route rip
   R2(config-router)#ver 2
   R2(config-router)#net 192.168.1.0
   R2(config-router)#net 192.168.2.0
   R2(config-router)#net 172.16.0.0
   R2(config-router)#no auto-summary
   R2(config-router)#passive-interface f0/0
       R3(config)#route rip
       R3(config-router)#ver 2
       R3(config-router)#net 172.16.0.0
       R3(config-router)#net 172.16.1.0
       R3(config-router)#no auto-summary
       R3(config-router)#passive-interface f0/0

实验四 交换机配置SSH

Switch>en
Switch#conf t
Switch(config)#hostname S1
S1(config)#enable secret 123456
S1(config)#interface vlan 1
S1(config-if)#ip address 192.168.0.254 255.255.255.0
S1(config-if)#no shut
S1(config-if)#exit
S1(config)#ip domain-name cisco.com //cisco.com为题目要求的网络的ip域名
S1(config)#ip ssh version 2
S1(config)#crypto key generate rsa
The name for the keys will be:S1.cisco.com
...
How many bits in the modulus[512]:1024 //1024为题目4中要求的1024位
...
S1(config)#username admin password ccna //admin和ccan为题目要求的用户名和密码
S1(config)#line vty 0 15
S1(config-line)#transport input ssh
S1(config-line)#login local
S1(config-line)#exit
S1(config)#ip ssh time-out 20 设置超时间为20秒
S1(config)#ip ssh authentication-retries 2 重试次数为2
S1(config)#show ip ssh
C:\>SSH-? //PC上查看ssh登录格式
Packet Tracer PC SSH
Usage:SSH-l username target
C:\>ping 192.168.0.254
C:\>ssh-l admin 192.168.0.254
Open
Password: //输入用户口令ccan
S1>en
实验四-2 交换机安全端口配置

Switch>en
Switch#conf t
Switch(config)#host S1
S1(config)#int f0/1
S1(config-if)#sw mode acc
S1(config-if)#sw port-security
S1(config-if)#switchport port-security mac-address 0009.7CB6.54BC //此mac地址为PC1的mac
S1(config-if)#switchport port-security violation protect 保护模式
S1(config-if)#int f0/2
S1(config-if)#sw mode acc
S1(config-if)#sw port-security
S1(config-if)#sw port-security maximum 2
S1(config-if)#sw port-security violation shut 关闭模式
S1(config-if)#int f0/3
S1(config-if)#sw mode acc
S1(config-if)#sw port-security
S1(config-if)#sw port-security maximum 3
S1(config-if)#sw port-security violation restrict 限制模式
S1(config-if)#sw port-security mac-address sticky 粘滞端口
实验五-1 交换机vlan中继配置

Switch0
Switch>
Switch>en
Switch#conf t
Switch(conf t)#host S1
S1(config)#vlan 10
S1(config-vlan)#name office
S1(config-vlan)#vlan 20
S1(config-vlan)#name student
S1(config-vlan)#exit
S1(config)#int range f0/1-4
S1(config-if-range)#sw mode acc
S1(config-if-range)#sw acc vlan 10
S1(config-if-range)#int range f0/5-8
S1(config-if-range)#sw mode acc
S1(config-if-range)#sw acc vlan 20
S1(config-if-range)#int f0/24
S1(config-if)#sw mode trunk
S1(config-if)#exit
Switch1
Switch>
Switch>en
Switch#conf t
Switch(config)#host S2
S2(config)#vlan 10
S2(config-vlan)#name office
S2(config-vlan)#vlan 20
S2(config-vlan)#name student
S2(config-vlan)#exit
S2(config)#int range f0/1-4
S2(config-if-range)#sw mode acc
S2(config-if-range)#sw acc vlan 10
S2(config-if-range)#int range f0/5-8
S2(config-if-range)#sw mode acc
S2(config-if-range)#sw acc vlan 20
S2(config-if-range)#int f0/24
S2(config-if)#sw mode trunk
实验五-2 传统vlan间路由配置

Switch0
Switch>
Switch>en
Switch#conf t
Switch(config)#host S1
S1(config)#vlan 10
S1(config-vlan)#vlan 20
S1(config-vlan)#exit
S1(config)#int f0/1
S1(config-if)#sw mode acc
S1(config-if)#sw acc vlan 10
S1(config-if)#int f0/23
S1(config-if)#sw mode acc
S1(config-if)#sw acc vlan 10
S1(config-if)#int f0/2
S1(config-if)#sw mode acc
S1(config-if)#sw acc vlan 20
S1(config-if)#int f0/24
S1(config-if)#sw mode acc
S1(config-if)#sw acc vlan 20
Router0
Router>
Router>en
Router#conf t
Router(config)#host R1
R1(config)#int f0/0
R1(config-if)#ip add 192.168.0.254 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int f0/1
R1(config-if)#ip add 192.168.1.254 255.255.255.0
R1(config-if)#no shut
实验五-3 单臂路由配置

Switch0
Switch>
Switch>en
Switch#conf t
Switch(config)#host S1
S1(config)#vlan 10
S1(config-vlan)#vlan 20
S1(config-vlan)#exit
S1(config)#int f0/1
S1(config-if)#sw mode acc
S1(config-if)#sw acc vlan 10
S1(config-if)#int f0/2
S1(config-if)#sw mode acc
S1(config-if)#sw acc vlan 20
S1(config-if)#exit
S1(config)#int f0/24
S1(config-if)#sw mode trunk
Router0
Router>
Router>en
Router#conf t
Router(config)#host R1
R1(config)#int f0/0.10
R1(config-subif)#encapsulation dot1Q 10 //dot1Q中1为数字1
R1(config-subif)#ip add 192.168.0.254 255.255.255.0
R1(config-subif)#int f0/0.20
R1(config-subif)#en dot 20
R1(config-subif)#ip add 192.168.1.254 255.255.255.0
R1(config-subif)#exit
R1(config)#int f0/0
R1(config-if)#no shut
实验五-4 三层交换机vlan间路由配置

Switch0
Switch>
Switch>en
Switch#conf t
Switch(config)#vlan 10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#int f0/1
Switch(config-if)#sw mode acc
Switch(config-if)#sw acc vlan 10
Switch(config-if)#int f0/2
Switch(config-if)#sw mode acc
Switch(config-if)#sw acc vlan 20
Switch(config-if)#exit
Switch(config)#int vlan 10
Switch(config-if)#ip add 192.168.0.254 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#int vlan 20
Switch(config-if)#ip add 192.168.1.254 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#exit
Switch(config)#ip routing
Switch(config)#host S1
S1(config)#
实验五-5 VTP配置

Switch0
Switch>
Switch>en
Switch#conf t
Switch(config)#host SW1
SW1(config)#int f0/1
SW1(config-if)#switchport mode trunk
SW1(config-if)#exit
SW1(config)#vtp mode server
SW1(config)#vtp domain cisco
SW1(config)#vtp password ccna
SW1(config)#exit
SW1(config)#exit
SW1#show vtp status
Switch1
Switch>
Switch>en
Switch#conf t
Switch(config)#host SW2
SW2(config)#int f0/1
SW2(config-if)#switchport mode trunk
SW2(config-if)#exit
SW2(config)#int f1/1
SW2(config-if)#switchport mode trunk
SW2(config-if)#exit
SW2(config)#exit
SW2#vlan database
SW2(vlan)#vtp mode transparent
SW2(vlan)#vtp domain cisco
SW2(vlan)#vtp password ccna
Switch2
Switch>
Switch>en
Switch#conf t
Switch(config)#host SW3
SW3(config)#int f1/1
SW3(config-if)#switchport mode trunk
SW3(config-if)#exit
SW3(config)#vtp mode client
SW3(config)#vtp domain cisco
SW3(config)#vtp password ccna

实验五-6 二层交换机链路聚合配置

Switch0
Switch>
Switch>en
Switch#conf t
Switch(config)#vlan 10
Switch(config-vlan)#name sales
Switch(config-vlan)#exit
Switch(config)#int f0/1
Switch(config-if)#switchport access vlan 10
Switch(config-if)#end
Switch#show vlan id 10
Switch#conf t
Switch(config)#int port-channel 1
Switch(config-if)#switchport mode trunk
Switch(config-if)#exit
Switch(config)#int range f0/23-24
Switch(config-if-range)#channel-group 1 mode active
Switch1
Switch>
Switch>en
Switch#conf t
Switch(config)#vlan 10
Switch(config-vlan)#name sales
Switch(config-vlan)#exit
Switch(config)#int f0/1
Switch(config-if)#switchport access vlan 10
Switch(config-if)#end
Switch#conf t
Switch(config)#int port-channel 1
Switch(config-if)#switchport mode trunk
Switch(config-if)#exit
Switch(config)#int range f0/23-24
Switch(config-if-range)#channel-group 1 mode active

实验七 标准ACL配置

Router5
Router (config) #host R1
R1 (config) #router rip
R1 (config-router) #version 2
R1 (config-router) #no auto
R1 (config-router) #network 192.168.0.0
R1 (config-router) #network 192.168.3.0
R1 (config-router) #exit
R1 (config) #access-list 1 deny 192.168.2.0 0.0.0.255
R1 (config) #access-list 1 permit any
R1 (config-std-nac1) #exit
R1 (config) #ip access-list standard denypc2
R1 (config-std-nac1) #deny host 192.168.2.1
R1 (config-std -nac1) #permit any
R1 (config-std-nac1) #exit
R1 (config) #int f2/0
R1(config-if)#ip access-group denypc2 in
R1(config-if)#exit
Router6
Router>en
Router#conf t
Router(config)#host R2
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#network no auto
R2(config-router)#network 192.168.1.0
R2(config-router)#network 192.168.2.0
R2(config-router)#network 192.168.3.0
实验八 扩展ACL配置

R2(config)#route rip
R2(config-router)#ver 2
R2(config-router)#net 10.10.10.0
R2(config-router)#net 192.168.1.0
R2(config-router)#no auto
R2(config-router)#exit
R2(config)#line vty 0 4
R2(config-line)#password cisco
R2(config-line)#login
R2(config-line)#enable secret cisco

R1(config)#route rip
R1(config-router)#ver 2
R1(config-router)#net 192.168.0.0
R1(config-router)#net 10.10.10.0
R1(config-router)#no auto
R1(config-router)#exit
R1(config)#access-list 100 permit tcp 192.168.0.0 0.0.0.255 host 192.168.1.1 eq www
R1(config)#access-list 100 deny tcp 192.168.0.0 0.0.0.255 host 192.168.1.1 eq ftp
R1(config)#access-list 100 deny tcp 192.168.0.0 0.0.0.255 host 10.10.10.2 eq telnet
R1(config)#access-list 100 deny tcp 192.168.0.0 0.0.0.255 host 192.168.1.254 eq telnet
R1(config)#access-list 100 deny icmp 192.168.0.0 0.0.0.255 host 10.10.10.2
R1(config)#access-list 100 deny icmp 192.168.0.0 0.0.0.255 host 192.168.1.254
R1(config)#access-list 100 permit ip any any
R1(config)#int f0/0
R1(config-if)#access-group 100 in
R1(config-if)#exit
实验九 DHCP服务器和中继配置

  1. Router>en
    Router#conf t
    Router(config)#ip dhcp excluded-address 192.168.10.1 192.168.10.9
    Router(config)#ip dhcp excluded-address 192.168.10.254
    Router(config)#ip dhcp excluded-address 192.168.20.1 192.168.20.9
    Router(config)#ip dhcp excluded-address 192.168.20.254
    Router(config)#ip dhcp excluded-address 192.168.30.1 192.168.30.9
    Router(config)#ip dhcp excluded-address 192.168.30.254
    Router(config)#ip dhcp pool lan-pool-1
    Router(dhcp-config)#network 192.168.10.0 255.255.255.0
    Router(dhcp-config)#default-router 192.168.10.1
    Router(dhcp-config)#dns-server 192.168.20.5
    Router(dhcp-config)#exit
    Router(config)#ip dhcp pool lan-pool-2
    Router(dhcp-config)#net 192.168.20.0 255.255.255.0
    Router(dhcp-config)#default-router 192.168.20.1
    Router(dhcp-config)#dns-server 192.168.20.5
    Router(dhcp-config)#exit
    Router(config)#ip dhcp pool lan-pool-3
    Router(dhcp-config)#net 192.168.30.0 255.255.255.0
    Router(dhcp-config)#default-router 192.168.30.1
    Router(dhcp-config)#dns-server 192.168.20.5
  2. Router>en
    Router#conf t
    Router(config)#int f0/0
    Router(config-if)#ip helper-address 172.16.10.1

实验十-1 静态ipv4nat配置实验

(在图中名为R1的路由器操作)
Router>en
Router#conf t
Router(config)#host R1
R1(config)#ip route 0.0.0.0 0.0.0.0 165.0.0.2
R1(config)#ip nat inside source static 192.168.0.1 165.0.0.3
R1(config-if)#int f0/0
R1(config-if)#ip nat inside
R1(config-if)#int s2/0
R1(config-if)#ip nat out //如果out不对就用outside

(在图中名为R2的路由器操作)
Router>en
Router#conf t
Router(config)#host R2
R2(config)#ip route 0.0.0.0 0.0.0.0 165.0.0.1
实验十-2 动态ipv4nat配置实验

(在图中R1的路由器进行操作)
Router>en
Router#conf t
Router(config)#host R1
R1(config)#ip route 0.0.0.0 0.0.0.0 209.165.0.2
R1(config)#ip nat pool add150 209.165.0.10 209.165.0.159 netmask 255.255.255.0
R1(config)#access-list 1 permit 192.168.1.0 0.0.0.255
R1(config)#ip nat inside source list 1 pool add150
R1(config)#int s2/0
R1(config-if)#ip nat out
R1(config-if)#int f0/0
R1(config-if)#ip nat inside
(在图中R2的路由器进行操作)
Router>en
Router#conf t
Router(config)#host R2
R2(config)#ip route 0.0.0.0 0.0.0.0 209.165.0.1

打赏
评论区
头像