本实验使用华为eNSP模拟器,采用了VLAN技术、链路聚合、DHCP、静态路由、NAT、SSH远程管理等技术,搭建了一个简单的公司内网环境。
实验环境:
实验目的:
1. 实现全网互通
2. 实现PC上网
3. 实现服务器被公网用户访问
4. 实现SSH远程管理
实验步骤:
1. 配置两台二层交换机
sw1
<Huawei>system-view [Huawei]sysname sw1 [sw1]vlan batch 10 20 [sw1]interface Eth-Trunk 1 #链路捆绑 [sw1-Eth-Trunk1]trunkport Ethernet 0/0/3 0/0/4 [sw1-Eth-Trunk1]port link-type trunk [sw1-Eth-Trunk1]port trunk allow-pass vlan 10 20 [sw1-Eth-Trunk1]quit [sw1]int e0/0/1 [sw1-Ethernet0/0/1]port link-type access [sw1-Ethernet0/0/1]port default vlan 10 [sw1]int e0/0/2 [sw1-Ethernet0/0/2]port link-type access [sw1-Ethernet0/0/2]port default vlan 20
sw2
<Huawei>system-view [Huawei]sysname sw2 [sw2]vlan batch 30 40 [sw2]interface Eth-Trunk 2 [sw2-Eth-Trunk1]trunkport Ethernet 0/0/3 0/0/4 [sw2-Eth-Trunk1]port link-type trunk [sw2-Eth-Trunk1]port trunk allow-pass vlan 30 40 [sw2-Eth-Trunk1]quit [sw2]int e0/0/1 [sw2-Ethernet0/0/1]port link-type access [sw2-Ethernet0/0/1]port default vlan 30 [sw2]int e0/0/2 [sw2-Ethernet0/0/2]port link-type access [sw2-Ethernet0/0/2]port default vlan 40
2. 配置三层交换机
3sw1
<Huawei>system-view [Huawei]sysname 3sw1 [3sw1]vlan batch 10 20 30 40 50 [3sw1]interface Eth-Trunk 1 [3sw1-Eth-Trunk1]trunkport GigabitEthernet 0/0/3 0/0/4 [3sw1-Eth-Trunk1]port link-type trunk [3sw1-Eth-Trunk1]port trunk allow-pass vlan 10 20 [3sw1-Eth-Trunk1]quit [3sw1]interface Eth-Trunk 2 [3sw1-Eth-Trunk2]trunkport GigabitEthernet 0/0/5 0/0/6 [3sw1-Eth-Trunk2]port link-type trunk [3sw1-Eth-Trunk2]port trunk allow-pass vlan 30 40 [3sw1-Eth-Trunk2]quit [3sw1]int g0/0/2 [3sw1-GigabitEthernet0/0/2]port link-type access [3sw1-GigabitEthernet0/0/2]port default vlan 50 [3sw1]dhcp enable [3sw1]int Vlanif 10 [3sw1-Vlanif10]ip add 192.168.1.254 24 [3sw1-Vlanif10]dhcp select interface [3sw1]int Vlanif 20 [3sw1-Vlanif20]ip add 192.168.2.254 24 [3sw1-Vlanif20]dhcp select interface [3sw1]int Vlanif 30 [3sw1-Vlanif30]ip add 192.168.3.254 24 [3sw1-Vlanif30]dhcp select interface [3sw1]int Vlanif 40 [3sw1-Vlanif40]ip add 192.168.4.254 24 [3sw1-Vlanif40]dhcp select interface [3sw1]int Vlanif 50 [3sw1-Vlanif10]ip add 192.168.5.254 24 [3sw1]int Vlanif 1 [3sw1-Vlanif1]ip add 192.168.6.1 24 [3sw1]ip route-static 0.0.0.0 0 192.168.6.2 #默认路由
3. 配置路由器
<Huawei>system-view [Huawei]sysname NAT [NAT]int g0/0/0 [NAT-GigabitEthernet0/0/0]ip add 192.168.6.2 24 [NAT-GigabitEthernet0/0/0]int g0/0/1 [NAT-GigabitEthernet0/0/1]ip add 100.1.1.1 30 [NAT]ip route-static 0.0.0.0 0 100.1.1.2 [NAT]ip route-static 192.168.1.0 24 192.168.6.1 [NAT]ip route-static 192.168.2.0 24 192.168.6.1 [NAT]ip route-static 192.168.3.0 24 192.168.6.1 [NAT]ip route-static 192.168.4.0 24 192.168.6.1 [NAT]ip route-static 192.168.5.0 24 192.168.6.1 [NAT]acl 2000 [NAT-acl-basic-2000]rule permit source any [NAT-acl-basic-2000]quit [NAT]int g0/0/1 [NAT-GigabitEthernet0/0/1]nat outbound 2000 #PC共享上网 [NAT-GigabitEthernet0/0/1]nat server protocol tcp global current-interface www inside 192.168.5.1 www #发布服务器
4. 配置ISP
<Huawei>system-view [Huawei]sysname ISP [ISP]int g0/0/1 [ISP-GigabitEthernet0/0/1]ip add 200.1.1.1 24 [ISP-GigabitEthernet0/0/1]int g0/0/0 [ISP-GigabitEthernet0/0/0]ip add 100.1.1.2 30
5. 验证DHCP、共享上网
(1)打开PC,选择DHCP,并应用,验证DHCP是否生效
(2)进入命令行,查看IP地址,并访问公网服务器,验证
6. 验证服务器是否发布成功
(1)在服务器上配置IP地址
(2)编写一个测试网页,并启动服务器
(3)在公网客户机上访问服务器,验证是否可以上网
7. 配置SSH,远程管理内部交换机、路由器
(1)在sw1上启用SSH
[sw1]user-interface vty 0 4 [sw1-ui-vty0-4]authentication-mode aaa #启用AAA认证 [sw1-ui-vty0-4]protocol inbound ssh #配置允许登录用户类型的协议 [sw1]aaa [sw1-aaa]local-user ysf password simple 123456 #设置用户和密码 [sw1-aaa]local-user ysf service-type ssh #设置用户可以登录的方式 [sw1-aaa]local-user ysf privilege level 5 #设置用户的级别 [sw1]stelnet server enable #开启ssh服务 [sw1]ssh user zhangsan authentication-type password #配置ssh用户的认证方式 [sw1]ssh user zhangsan service-type stelnet #在路由器中不用配置这条命令 [sw1]ip route-static 0.0.0.0 0 192.168.1.254 [sw1]int vl 10 [sw1-Vlanif10]ip add 192.168.1.100 24 #配置管理地址
(2)在NAT路由器上管理sw1
[NAT]ssh client first-time enable #启用SSH客户端 [NAT]stelnet 192.168.1.100 Please input the username:ysf #输入用户 Trying 192.168.1.100 ... Press CTRL+K to abort Connected to 192.168.1.100 ... Enter password: #输入密码 Info: The max number of VTY users is 5, and the number of current VTY users on line is 1. The current login time is 2018-04-11 23:21:21. <sw1> #成功进入sw1管理界面
如果需要在公网远程管理sw1,需要设置一下NAT
(1)设置NAT
同理,只有改一下公网的端口,可以管理所有的设备
[NAT]int g0/0/1 [NAT-GigabitEthernet0/0/1]nat server protocol tcp global current-interface 2200 inside 192.168.1.100 22
(2)在公网上远程管理sw1
[ISP]ssh client first-time enable [ISP]stelnet 100.1.1.1 2200 Please input the username:ysf Trying 100.1.1.1 ... Press CTRL+K to abort Connected to 100.1.1.1 ... Enter password: Info: The max number of VTY users is 5, and the number of current VTY users on line is 1. The current login time is 2018-04-11 23:34:45. <sw1> #成功进入sw1管理界面
原文地址:http://blog.51cto.com/yangshufan/2097185
时间: 2024-11-07 01:27:45