1.实验拓扑
2.实验要求
要求:(设备名称按照拓扑标识修改,注意区分大小写)
1、ISP路由器仅配置IP地址
2、test-1和test-2仅作为代替终端设备进行测试使用,路由采用静态路由
3、R1/R2之间使用OSPF做到内网全通,单区域,OSPF使用一条命令进行宣告(直接宣告192.168.1.0网段);router-ID分别为1.1.1.1和2.2.2.2;OSPF进程为1
4、PC1-PC4使用DHCP获取地址,地址池名称使用1,2
5、PC1不能访问PC5,acl编号为3000
6、R2出口只拥有一个公网IP
7、test-1设备可以登录内网telnet服务器,test-2不行;acl编号为3000
8、telnet服务器的账号密码为huawei/123456
9、内网用户可以正常访问ISP(边界做默认路由)
10、公网设备的路由表不能有私网的路由,使用nat(acl编号为2000)
11、内网设备的路由表不能有公网的路由,边界下发默认路由
12、VLAN及IP规划查看附件材料(所有trunk链路按照最少VLAN透传原则放通)
3.附件资料
4.实验步骤
1.给两个交换机配置VLAN并设置永不超时
LW1
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn lw1
[lw1]user-interface console 0
[lw1-ui-console0]idle-t
[lw1-ui-console0]idle-timeout 0 0
[lw1-ui-console0]qu
[lw1]vlan batch 2 3 4
[lw1]int g 0/0/2
[lw1-GigabitEthernet0/0/2]port link-type access
[lw1-GigabitEthernet0/0/2]port default
[lw1-port-group-default]port default vlan 2
[lw1]int g 0/0/3
[lw1-GigabitEthernet0/0/3]port link-type access
[lw1-GigabitEthernet0/0/3]por default vlan 3
[lw1-GigabitEthernet0/0/3]int g 0/0/4
[lw1-GigabitEthernet0/0/4]port link-type access
[lw1-GigabitEthernet0/0/4]port default vlan 4
[lw1-GigabitEthernet0/0/4]int g 0/0/1
[lw1-GigabitEthernet0/0/1]port link-type trunk
[lw1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3 4
[lw1-GigabitEthernet0/0/1]qu
LW2
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn lw2
[lw2]user-interface console 0
[lw2-ui-console0]idle-timeout 0 0
[lw2]vlan batch 20 30
[lw2]int g 0/0/2
[lw2-GigabitEthernet0/0/2]port link-type access
[lw2-GigabitEthernet0/0/2]port default vlan 20
[lw2-GigabitEthernet0/0/2]int g 0/0/3
[lw2-GigabitEthernet0/0/3]port link-type access
[lw2-GigabitEthernet0/0/3]port default vlan 30
[lw2-GigabitEthernet0/0/3]int g 0/0/1
[lw2-GigabitEthernet0/0/1]port link-type trunk
[lw2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3 4
[lw2-GigabitEthernet0/0/1]port trunk allow-pass vlan 20 30
[lw2-GigabitEthernet0/0/1]qu
查看VLAN
//以LW2为例
[lw2]display vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up; D: Down; TG: Tagged; UT: Untagged;
MP: Vlan-mapping; ST: Vlan-stacking;
#: ProtocolTransparent-vlan; *: Management-vlan;
--------------------------------------------------------------------------------
VID Type Ports
--------------------------------------------------------------------------------
1 common UT:GE0/0/1(U) GE0/0/4(D) GE0/0/5(D) GE0/0/6(D)
GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D)
GE0/0/11(D) GE0/0/12(D) GE0/0/13(D) GE0/0/14(D)
GE0/0/15(D) GE0/0/16(D) GE0/0/17(D) GE0/0/18(D)
GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D)
GE0/0/23(D) GE0/0/24(D)
20 common UT:GE0/0/2(U)
TG:GE0/0/1(U)
30 common UT:GE0/0/3(U)
TG:GE0/0/1(U)
VID Status Property MAC-LRN Statistics Description
--------------------------------------------------------------------------------
1 enable default enable disable VLAN 0001
20 enable default enable disable VLAN 0020
30 enable default enable disable VLAN 0030
[lw2]
2.进行虚拟子接口封装,进行DHCP服务
R1
[Huawei]sysname R1
[R1]user-interface console 0
[R1-ui-console0]int g 0/0/0.1
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[R1-GigabitEthernet0/0/0.1]ip add 192.168.1.30 27
[R1-GigabitEthernet0/0/0.1]int g 0/0/0.2
[R1-GigabitEthernet0/0/0.2]dot1q termination vid 3
[R1-GigabitEthernet0/0/0.2]ip add 192.168.1.62 27
[R1-GigabitEthernet0/0/0.1]int g 0/0/0.3
[R1-GigabitEthernet0/0/0.3]dot1q termination vid 4
[R1-GigabitEthernet0/0/0.3]ip add 192.168.1.158 27
[R1-GigabitEthernet0/0/0.3]qu
[R1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]ip pool 1
Info: It's successful to create an IP address pool.
[R1-ip-pool-1]network 192.168.1.0 mask 27
[R1-ip-pool-1]gateway-list 192.168.1.30
[R1-ip-pool-1]dns-list 8.8.8.8
[R1-ip-pool-1]qu
[R1]ip pool 2
Info: It's successful to create an IP address pool.
[R1-ip-pool-2]network 192.168.1.32 mask 27
[R1-ip-pool-2]gateway-list 192.168.1.62
[R1-ip-pool-2]dns-list 8.8.8.8
[R1-ip-pool-2]qu
[R1]int g 0/0/0.1
[R1-GigabitEthernet0/0/0.1]dhcp select global
[R1-GigabitEthernet0/0/0.1]arp broadcast enable
[R1-GigabitEthernet0/0/0.1]int g 0/0/0.2
[R1-GigabitEthernet0/0/0.2]dhcp select global
[R1-GigabitEthernet0/0/0.2]arp broadcast enable
[R1-GigabitEthernet0/0/0.2]int g 0/0/0.3
[R1-GigabitEthernet0/0/0.3]dhcp select global
[R1-GigabitEthernet0/0/0.3]arp broadcast enable
[R1-GigabitEthernet0/0/0.3]qu
R2
[R2]user-interface console 0
[R2-ui-console0]idle-timeout 0 0
[R2-ui-console0]int g 0/0/0.1
[R2-GigabitEthernet0/0/0.1]dot1q termination vid 20
[R2-GigabitEthernet0/0/0.1]ip add 192.168.1.94 27
[R2-GigabitEthernet0/0/0.1]int g 0/0/0.2
[R2-GigabitEthernet0/0/0.2]dot1q termination vid 30
[R2-GigabitEthernet0/0/0.2]ip add 192.168.1.126 27
[R2-GigabitEthernet0/0/0.2]qu
[R2]
[R2]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R2]ip pool 1
Info: It's successful to create an IP address pool.
[R2-ip-pool-1]network 192.168.1.64 mask 27
[R2-ip-pool-1]gateway-list 192.168.1.94
[R2-ip-pool-1]dns-list 8.8.8.8
[R2-ip-pool-1]qu
[R2]ip pool 2
Info: It's successful to create an IP address pool.
[R2-ip-pool-2]network 192.168.1.96 mask 27
[R2-ip-pool-2]gateway-list 192.168.1.126
[R2-ip-pool-2]dns-list 8.8.8.8
[R2-ip-pool-2]qu
[R2]int g 0/0/0.1
[R2-GigabitEthernet0/0/0.1]dhcp select global
[R2-GigabitEthernet0/0/0.1]arp broadcast enable
[R2-GigabitEthernet0/0/0.1]int g 0/0/0.2
[R2-GigabitEthernet0/0/0.2]dhcp select global
[R2-GigabitEthernet0/0/0.2]arp broadcast enable
[R2-GigabitEthernet0/0/0.2]qu
[R2]int g 0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.1.162 30
[R2-GigabitEthernet0/0/1]int g 0/0/2
[R2-GigabitEthernet0/0/2]ip add 202.1.1.1 30
[R2-GigabitEthernet0/0/2]qu
3.配置路由器的接口IP
R1
[r1]int g 0/0/1
[r1-GigabitEthernet0/0/1]ip address 192.168.1.161 30
[r1-GigabitEthernet0/0/1]qu
[r1]
R2
[R2]int g 0/0/1
[R2-GigabitEthernet0/0/1]ip address 192.168.1.162 30
[R2-GigabitEthernet0/0/1]int g0/0/2
[R2-GigabitEthernet0/0/2]ip address 202.1.1.1 30
[R2-GigabitEthernet0/0/2]qu
[R2]
test-1
[Huawei]sys test-1
[test-1]user-interface console 0
[test-1-ui-console0]idle-timeout 0 0
[test-1-ui-console0]qu
[test-1]int g 0/0/0
[test-1-GigabitEthernet0/0/0]ip address 203.1.1.1 24
[test-1-GigabitEthernet0/0/0]qu
test-2
[Huawei]sysname test-2
[test-2]user-interface console 0
[test-2-ui-console0]idle-timeout 0 0
[test-2-ui-console0]qu
[test-2]int g 0/0/0
[test-2-GigabitEthernet0/0/0]ip address 203.1.1.2 24
[test-2-GigabitEthernet0/0/0]qu
telnet server
[Huawei]sys Telnet Server
[Telnet Server]user-interface console 0
[Telnet Server-ui-console0]idle-timeout 0 0
[Telnet Server-ui-console0]qut
[Telnet Server]int g 0/0/0
[Telnet Server-GigabitEthernet0/0/0]ip address 192.168.1.129 27
[Telnet Server-GigabitEthernet0/0/0]qu
LSP
[Huawei]sys ISP
[ISP]user-interface console 0
[ISP-ui-console0]idle-timeout 0 0
[ISP-ui-console0]qu
[ISP]int g 0/0/0
[ISP-GigabitEthernet0/0/0]ip address 202.1.1.2 30
[ISP-GigabitEthernet0/0/0]int g 0/0/1
[ISP-GigabitEthernet0/0/1]ip address 203.1.1.254 24
[ISP-GigabitEthernet0/0/1]qu
4.配置ospf实现R1与R2之间的通信
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.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]qu
R2
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]qu
5.在Telnet 服务器上配置缺省路由
telnet server
[Telnet Server]ip route-static 0.0.0.0 0 192.168.1.158
[Telnet Server]
6.pc端获取IP ,PC5手动添加
7.测试内网连通性
telnet server
[Telnet Server]ping 192.168.1.158
PING 192.168.1.158: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.158: bytes=56 Sequence=1 ttl=255 time=90 ms
Reply from 192.168.1.158: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 192.168.1.158: bytes=56 Sequence=3 ttl=255 time=50 ms
Reply from 192.168.1.158: bytes=56 Sequence=4 ttl=255 time=50 ms
Reply from 192.168.1.158: bytes=56 Sequence=5 ttl=255 time=50 ms
--- 192.168.1.158 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/58/90 ms
[Telnet Server]ping 192.168.1.125
PING 192.168.1.125: 56 data bytes, press CTRL_C to break
Request time out
Reply from 192.168.1.125: bytes=56 Sequence=2 ttl=126 time=60 ms
Reply from 192.168.1.125: bytes=56 Sequence=3 ttl=126 time=90 ms
Reply from 192.168.1.125: bytes=56 Sequence=4 ttl=126 time=90 ms
Reply from 192.168.1.125: bytes=56 Sequence=5 ttl=126 time=90 ms
--- 192.168.1.125 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 60/82/90 ms
[Telnet Server]ping 192.168.1.29
PING 192.168.1.29: 56 data bytes, press CTRL_C to break
Request time out
Reply from 192.168.1.29: bytes=56 Sequence=2 ttl=127 time=90 ms
Reply from 192.168.1.29: bytes=56 Sequence=3 ttl=127 time=80 ms
Reply from 192.168.1.29: bytes=56 Sequence=4 ttl=127 time=90 ms
Reply from 192.168.1.29: bytes=56 Sequence=5 ttl=127 time=70 ms
--- 192.168.1.29 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 70/82/90 ms
8.给R2配置缺省指向外网,并进行OSPF,配置NAT技术
[R2]ip route-static 0.0.0.0 0 202.1.1.2
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]default-route-advertise
[R2-ospf-1]qu
[R2]acl 2000
[R2-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R2-acl-basic-2000]qu
[R2]int g 0/0/2
[R2-GigabitEthernet0/0/2]nat outbound 2000
[R2-GigabitEthernet0/0/2]qu
9.测试内网与外网P5的连通性
10.test-1和test-2配置静态路由
test-1
[test-1]ip route-static 202.1.1.0 30 203.1.1.254
test-2
[test-2]ip route-static 202.1.1.0 30 203.1.1.254
11.查看ISP的路由表
LSP
[LSP]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
202.1.1.0/30 Direct 0 0 D 202.1.1.2 GigabitEthernet
0/0/0
202.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
202.1.1.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
203.1.1.0/24 Direct 0 0 D 203.1.1.254 GigabitEthernet
0/0/1
203.1.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
203.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[LSP]
12.配置ACL,不能使pc1访问pc5
[R1]acl 3000
[R1-acl-adv-3000]rule deny icmp source 192.168.1.29 0 destination 203.1.1.100 0
[R1-acl-adv-3000]qu
[R1]int g 0/0/0.1
[R1-GigabitEthernet0/0/0.1]traffic-filter inbound acl 3000
[R1-GigabitEthernet0/0/0.1]qu
13.在telnet server路由器,进行配置telnet
telnet server
[Telnet Server]aaa
[Telnet Server-aaa]local-user huawei password cipher 123456 privilege level 15
Info: Add a new user.
[Telnet Server-aaa]local-user huawei service-type telnet
[Telnet Server-aaa]qu
[Telnet Server]user-interface vty 0 4
[Telnet Server-ui-vty0-4]authentication-mode aaa
[Telnet Server-ui-vty0-4]qu
14.配置映射端口
R2配置
[R2]int g 0/0/2
[R2-GigabitEthernet0/0/2]nat server protocol tcp global current-interface 23 inside 192.168.1.129 23
Are you sure to continue?[Y/N]:y
[R2-GigabitEthernet0/0/2]qu
[R2]
测试在test-1远程登录
<test-1>telnet 202.1.1.1
Press CTRL_] to quit telnet mode
Trying 202.1.1.1 ...
Connected to 202.1.1.1 ...
Login authentication
Username:huawei
Password:
-----------------------------------------------------------------------------
User last login information:
-----------------------------------------------------------------------------
Access Type: Telnet
IP-Address : 203.1.1.1
Time : 2024-09-25 15:19:47-08:00
-----------------------------------------------------------------------------
<Telnet Server>qu
Configuration console exit, please retry to log on
The connection was closed by the remote host
<test-1>
15.配置ACL拒绝test-2的包
LSP
[LSP]acl 3000
[LSP-acl-adv-3000]rule deny tcp source 203.1.1.2 0 destination-port eq 23
[LSP-acl-adv-3000]qu
[LSP]int g 0/0/1
[LSP-GigabitEthernet0/0/1]traffic-filter inbound acl 3000
[LSP-GigabitEthernet0/0/1]qu
test-2测试
<test-2>telnet 202.1.1.1
Press CTRL_] to quit telnet mode
Trying 202.1.1.1 ...
Error: Can't connect to the remote host
<test-2>