HCIA网络初级综合实验
一、实验拓扑
二、实验说明
由于模拟器PC设备不能使用telnet,固用路由器设备模拟PC1
三、实验要求
- ISP路由容只配置ip地址,之后不得进行其他任何配置
- 内部整个网络基于192.168.1.0/24进行地址规划
- R1/2之间启动OSPF协议,单区城
- P1-P4自动获取ip地址
- PC1不能teinetR1,PC1外的其他内网PC可以teinet.
- PC1-PC4 可以访问PC5,R2的公网接口只拥有一个公有IP 12.1.1.1
- 外部的client可以通过城名访问http server.
- ISP路由telnet12.1.1.1, 最终成功登录到R1上
四、实验步骤
1)ip地址规划
192.168.1.0/24 划分成3个子网
192.168.1.0/26 --划分成拥有两个接口ip
192.168.1.0/30
192.168.1.64/26 --划分成两个子网
192.168.1.64/27 vlan2
192.168.1.96/27 vlan3
192.168.1.128/26 --划分成两个子网
192.168.1.128/27 vlan2
192.168.1.160/27 vlan3
2)划分vlan
R1-sw1:
1.创建vlan
[sw1]vlan batch 2 to 3
2.将接口划入vlan
[sw1]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/2
[sw1-port-group]port link-type access
[sw1-port-group]port default vlan 2
[sw1]int e0/0/3
[sw1-Ethernet0/0/3]port link-type access
[sw1-Ethernet0/0/3]port default vlan 3
3.创建trunk干道
[sw1]interface GigabitEthernet 0/0/1
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
4.配置路由器接口ip创建子接口
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.1.1 30
[R1-GigabitEthernet0/0/1]q
[R1]int g0/0/0.1
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[R1-GigabitEthernet0/0/0.1]arp broadcast enable
[R1-GigabitEthernet0/0/0.1]ip add 192.168.1.65 27
[R1-GigabitEthernet0/0/0.1]q
[R1]int g0/0/0.2
[R1-GigabitEthernet0/0/0.2]dot1q termination vid 3
[R1-GigabitEthernet0/0/0.2]arp broadcast enable
[R1-GigabitEthernet0/0/0.2]ip address 192.168.1.97 27
5.创建dhcp池塘自动获取IP
[R1]dhcp enable
[R1]ip pool v2
[R1-ip-pool-v2]network 192.168.1.64 mask 255.255.255.224
[R1-ip-pool-v2]gateway-list 192.168.1.65
[R1-ip-pool-v2]dns-list 114.114.114.114
[R1-ip-pool-v2]q
[R1]ip pool v3
[R1-ip-pool-v3]network 192.168.1.96 mask 255.255.255.224
[R1-ip-pool-v3]gateway-list 192.168.1.97
[R1-ip-pool-v3]dns-list 114.114.114.114
[R1]int g0/0/0.1 //注意在子接口开启dhcp
[R1-GigabitEthernet0/0/0.1]dhcp select global
[R1-GigabitEthernet0/0/0.1]q
[R1]int g0/0/0.2
[R1-GigabitEthernet0/0/0.2]dhcp select global
R2-sw2
1.创建vlan
[sw2]vlan batch 2 to 3
2.将接口划入vlan
[sw2]interface Ethernet0/0/1
[sw2-Ethernet0/0/1]port link-type access
[sw2-Ethernet0/0/1]port default vlan 2
[sw2]interface Ethernet0/0/2
[sw2-Ethernet0/0/2]port link-type access
[sw2-Ethernet0/0/2]port default vlan 3
3.创建trunk干道
[sw2]interface GigabitEthernet 0/0/1
[sw2-GigabitEthernet0/0/1]port link-type trunk
[sw2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
4.配置路由器接口ip创建子接口
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/0]ip address 192.168.1.2 30
[R2]interface g0/0/2
[R2-GigabitEthernet0/0/2]ip add 12.1.1.1 24
[R2]int g0/0/0.1
[R2-GigabitEthernet0/0/0.1]dot1q termination vid 2
[R2-GigabitEthernet0/0/0.1]arp broadcast enable
[R2-GigabitEthernet0/0/0.1]ip add 192.168.1.129 27
[R2]int g0/0/0.2
[R2-GigabitEthernet0/0/0.2]dot1q termination vid 3
[R2-GigabitEthernet0/0/0.2]arp broadcast enable
[R2-GigabitEthernet0/0/0.2]ip add 192.168.1.161 27
5.创建dhcp池塘自动获取IP
[R2]dhcp enable
[R2-ip-pool-v2]network 192.168.1.128 mask 255.255.255.224
[R2-ip-pool-v2]gateway-list 192.168.1.129
[R2-ip-pool-v2]dns-list 114.114.114.114
[R2-ip-pool-v2]q
[R2]ip pool v3
[R2-ip-pool-v3]network 192.168.1.160 mask 255.255.255.224
[R2-ip-pool-v3]gateway-list 192.168.1.161
[R2-ip-pool-v3]dns-list 114.114.114.114
[R2]interface g0/0/0.1
[R2-GigabitEthernet0/0/0.1]dhcp select global
[R2]int g0/0/0.2
[R2-GigabitEthernet0/0/0.2]dhcp select global
3)实现全网可达–OSPF协议
R1
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]q
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]network 192.168.1.65 0.0.0.0
[R1-ospf-1-area-0.0.0.1]network 192.168.1.97 0.0.0.0
R2
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1-area-0.0.0.0]network 192.168.1.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]q
[R2-ospf-1]area 2
[R2-ospf-1-area-0.0.0.2]network 192.168.1.129 0.0.0.0
[R2-ospf-1-area-0.0.0.2]network 192.168.1.161 0.0.0.0
检测是否能ping通:
OSPF优化
1.汇总
[R1]ospf 1
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]abr-summary 192.168.1.64 255.255.255.192
[R2]ospf 1
[R2-ospf-1]area 2
[R2-ospf-1-area-0.0.0.2]abr-summary 192.168.1.128 255.255.255.192
2.做沉默接口(不会再有OSPF给底下人发hello包)
[R1]ospf 1
[R1-ospf-1]silent-interface g0/0/0.1
[R1-ospf-1]silent-interface g0/0/0.2
[R2]ospf 1
[R2-ospf-1]silent-interface g0/0/0.1
[R2-ospf-1]silent-interface g0/0/0.2
切记:不能配在连接路由器的接口上
3.OSPF认证
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher mima123
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher mima123
因为之前ospf做了优化--汇总,及在nat转换时还要做缺省,为了汇总与缺省之间不会发生环路,需要写一个静态路由将它指向黑洞
[R1]ip route-static 192.168.1.0 26 NULL 0
[R2]ip route-static 192.168.1.128 26 NULL 0
4)实现要求5,Telnet
[R1]aaa
[R1-aaa]local-user yonghu password cipher mima123
[R1-aaa]local-user yonghu service-type telnet
[R1-aaa]local-user yonghu privilege level 15
[R1-aaa]q
[R1]user-interface vty 0 4
[R1-ui-vty0-4]authentication-mode aaa
路由器模拟PC1,通过R1的DHCP自动获取IP方法
[PC1]dhcp enable
[PC1]interface g0/0/1
[PC1-GigabitEthernet0/0/1]ip address dhcp-alloc //给路由器接口自动获取IP
结果:
此时没有做任何权限,该网段任何人都被允许登录
创建ACL访问控制列表,对PC1设置权限
[R1]acl 3000
[R1-acl-adv-3000]rule deny tcp source 192.168.1.92 0 destination 192.168.1.1 0 destination-port eq 23
[R1-acl-adv-3000]rule deny tcp source 192.168.1.92 0 destination 192.168.1.65 0 destination-port eq 23
[R1-acl-adv-3000]rule deny tcp source 192.168.1.92 0 destination 192.168.1.97 0 destination-port eq 23
[R1-acl-adv-3000]display this
[V200R003C00]
#
acl number 3000
rule 5 deny tcp source 192.168.1.92 0 destination 192.168.1.1 0 destination-port eq telnet
rule 10 deny tcp source 192.168.1.92 0 destination 192.168.1.65 0 destination-port eq telnet
rule 15 deny tcp source 192.168.1.92 0 destination 192.168.1.97 0 destination-port eq telnet
#
return
//注意在vlan2的子接口0.1接口调用
[R1-acl-adv-3000]q
[R1]
[R1]int g0/0/0.1
[R1-GigabitEthernet0/0/0.1]tra
[R1-GigabitEthernet0/0/0.1]traffic-filter inbound acl 3000
结果:PC1不能远程登录R1设备
5)实现要求6,局域网访问外部网
首先,要局域网访问外部网,永远要做两件事
1.缺省—内网访问外网出去的路
2.Nat – 从外网回来的路
1.缺省---内网访问外网出去的路
[R2]ospf 1 //通过ospf给r1写一条缺省
[R2-ospf-1]default-route-advertise a
[R2-ospf-1]default-route-advertise always
//R2给自己写出去的缺省
[R2]ip route-static 0.0.0.0 0.0.0.0 12.1.1.2
查看R1路由表,有一条通过OSPF学到的下一跳为192.168.1.2的缺省路由
结果:PC1 ping通 1.1.1.2
2.Nat -- 从外网回来的路
//定义acl表抓取192.168.1.0网段所有流量
[R2]acl 2000
[R2-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R2-acl-basic-2000]q
//acl2000表里的人从这个接口出去都会被替换成 12.1.1.1 并且会端口映射,一对多
[R2]int g0/0/2
[R2-GigabitEthernet0/0/2]nat outbound 2000
此时,实验5内网所有用户都可以访问外网的PC5了
6)实现要求7,外网的client1可以访问内容的http服务器
要求6设置的是nat的一对多,这个要求在不添加新的公网IP地址情况下,需要做一个指定的80端口映射,将内网的http服务器的IP地址80端口 通过 NAT 与 外网的12.1.1.1:80端口 绑定
要求7 指定端口映射
[R2]int g0/0/2
//下面命令会报错,可能会与模拟器设备有关
[R2-GigabitEthernet0/0/2]nat server protocol tcp global 12.1.1.1 80 inside 192.168.1.100 80
Error: The address conflicts with interface or ARP IP.
//如果上述命令错误,使用下面的命令--当前接口
[R2-GigabitEthernet0/0/2]nat server protocol tcp global current-interface 80 inside 192.168.1.100 80
Warning:The port 80 is well-known port. If you continue it may cause function failure.
Are you sure to continue?[Y/N]:y
[R2-GigabitEthernet0/0/2]display this
[V200R003C00]
#
interface GigabitEthernet0/0/2
ip address 12.1.1.1 255.255.255.0
nat server protocol tcp global current-interface www inside 192.168.1.100 www
nat outbound 2000
#
return
配置DNS解析服务,通过域名访问
测试结果:
7)实现要求8, ISP路由telnet12.1.1.1, 最终成功登录到R1上
解析:要求8和要求7是一样的,7是要求访问12.1.1.1时访问到内网的http服务器,8的要求是访问12.1.1.1时,telnet登录的是R1,所以同样是做一个telnet协议 TCP 23端口的绑定。
[R2-GigabitEthernet0/0/2]nat server protocol tcp global current-interface 23 inside 192.168.1.1 23
Warning:The port 23 is well-known port. If you continue it may cause function failure.
Are you sure to continue?[Y/N]:y
要求8结果:
自此,该实验的所有要求都已经达到,花了好几个小时,希望可以帮助自己理解,同时也可以给大家带来一些理解。哈哈哈~