1:实验需求
公司拥有多个部门且位于不同网段,各部门均有访问internet的需求。现要求用户通过二层交换机和路由器访问外部网络,且要求路由器作为用户的网关。
我们按照图示的ip地址进行配置,最终的结果是pc1和pc2可以ping通公网地址192.169.1.2.
2:网络拓补图
这里多说一句哈,华为的ensp模拟器有的路由器nat配置了不生效,我在这里使用的是ar1220系列。
3:实验过程
core
syenter system view, return user view with ctrl+z.[huawei]undo info-center enable info: information center is disabled.[huawei]sysname core[core]vlan batch 2 3 100 //创建vlan 2 3 100备用info: this operation may take a few seconds. please wait for a moment...done.[core]dhcp enable //全局使能dhcpinfo: the operation may take a few seconds. please wait for a moment.done.[core]interface vlanif 2 //进入vlanif接口配置ip,dhcp的方式是基于接口[core-vlanif2]ip address 192.168.2.254 24[core-vlanif2]dhcp select interface [core-vlanif2]quit [core]interface vlanif 3[core-vlanif3]ip add 192.168.3.254 24 [core-vlanif3]dhcp select interface [core-vlanif3]quit [core]interface vlanif 100[core-vlanif100]ip add 192.168.100.2 24[core-vlanif100]quit [core]interface gigabitethernet 0/0/1 //设置终端链路类型access[core-gigabitethernet0/0/1]port link-type access [core-gigabitethernet0/0/1]port default vlan 2 [core-gigabitethernet0/0/1]quit [core]interface gigabitethernet 0/0/2[core-gigabitethernet0/0/2]port link-type access [core-gigabitethernet0/0/2]port default vlan 3[core-gigabitethernet0/0/2]quit [core]interface gigabitethernet 0/0/3 //设置链路终端类型,设置为access,路由器才能识别,或者trunk端口设置pvid。[core-gigabitethernet0/0/3]port link-type access [core-gigabitethernet0/0/3]port default vlan 100[core-gigabitethernet0/0/3]quit [core]ip route-static 0.0.0.0 0.0.0.0 192.168.100.1 //写一条默认路由,下一跳地址是对端的路由器
router
sy system-view enter system view, return user view with ctrl+z. [huawei]undo info-center enable info: information center is disabled.[huawei]sysname router[router]interface gigabitethernet 0/0/1 //我们配置内网的ip接口[router-gigabitethernet0/0/1]ip add 192.168.100.1 24[router-gigabitethernet0/0/1]quit [router]ip route-static 192.168.0.0 16 192.168.100.2 //我们配置到内网的回程路由,即192.168.x.x均可以匹配[router]ip route-static 0.0.0.0 0.0.0.0 192.169.1.2 //设置一条默认路由去公网[router]interface gigabitethernet 0/0/0 //配置公网的ip地址[router-gigabitethernet0/0/0]ip address 192.169.1.1 24 [router-gigabitethernet0/0/0]quit [router]acl 2000 //建基本acl2000[router-acl-basic-2000]rule permit source 192.168.0.0 0.0.255.255 //允许192.168.x.x的网段[router-acl-basic-2000]quit [router]interface gigabitethernet 0/0/0 //进入外网接口,调用acl2000[router-gigabitethernet0/0/0]nat outbound 2000 //nat引用[router-gigabitethernet0/0/0]quit [router]display nat session all //这里我们可以看到nat会话 nat session table information: protocol : icmp(1) srcaddr vpn : 192.168.2.253 destaddr vpn : 192.169.1.2 type code icmpid : 0 8 890 nat-info new srcaddr : 192.169.1.1 new destaddr : ---- new icmpid : 10259 protocol : icmp(1) srcaddr vpn : 192.168.2.253 destaddr vpn : 192.169.1.2 type code icmpid : 0 8 888 nat-info new srcaddr : 192.169.1.1 new destaddr : ---- new icmpid : 10257 protocol : icmp(1) srcaddr vpn : 192.168.2.253 destaddr vpn : 192.169.1.2 type code icmpid : 0 8 889 nat-info new srcaddr : 192.169.1.1 new destaddr : ---- new icmpid : 10258 protocol : icmp(1) srcaddr vpn : 192.168.2.253 destaddr vpn : 192.169.1.2 type code icmpid : 0 8 887 nat-info new srcaddr : 192.169.1.1 new destaddr : ---- new icmpid : 10256 protocol : icmp(1) srcaddr vpn : 192.168.2.253 destaddr vpn : 192.169.1.2 type code icmpid : 0 8 886 nat-info new srcaddr : 192.169.1.1 new destaddr : ---- new icmpid : 10255
公网路由器
sy system-view //我们给它设置一个测试用的ip地址[huawei]interface gigabitethernet 0/0/0[huawei-gigabitethernet0/0/0]ip add 192.169.1.2 24 [huawei-gigabitethernet0/0/0]quit [huawei]ping 192.169.1.1 //测试和公司公网ip的连通性 ping 192.169.1.1: 56 data bytes, press ctrl_c to break reply from 192.169.1.1: bytes=56 sequence=1 ttl=255 time=90 ms reply from 192.169.1.1: bytes=56 sequence=2 ttl=255 time=20 ms reply from 192.169.1.1: bytes=56 sequence=3 ttl=255 time=30 ms reply from 192.169.1.1: bytes=56 sequence=4 ttl=255 time=30 ms reply from 192.169.1.1: bytes=56 sequence=5 ttl=255 time=20 ms --- 192.169.1.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 20/38/90 ms[huawei]
测试
我们使用pc1和pc2分别ping公网地址,如下图所示
会话信息
商汤科技在日本设立的自动驾驶试验场估值达到了45亿美元
2.5软线与2.5硬线区别_家装硬线好还是软线好_硬线价格大概是多少
上海地市商会秘书长考察团到访深兰,共同推动各地传统产业转型升级
意法半导体公布上半年财报
实现三相正弦波电压发生器的电路设计
ENSP华为路由器出口NAT实验设计
CPLD在DSP系统中的应用设计
刘儿兀:下一代室内定位技术的现状与研发趋势
视觉相机技术应用于汽车座椅泡棉检查方案
猎豹移动“未来小镇”网红服务机器人
区块链应用层为什么说需要拿破仑
软件定义的无线电的架构特点与应用
89个嵌入式相关概念你懂几个?
优酷科技跨年:郝景芳创作科幻剧情,人工智能小冰受邀出演关键角色
Bitfusion宣布推出Bitfusion Flex Beta版
5G SA架构下的三种5G语音方案介绍
精心整理的3D封装
基于BLINK的DCS控制系统仿真
我们该如何正确采用继电器的报警情况
2018年一季度全球手机单品销量排行榜