宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

拓扑图

适合内部流量较大的小网络。

1、配置路由器基础部分

The device is running!
system-view #进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR #修改设备名称
[AR]interface GigabitEthernet 0/0/0 #进入接口0/0/0
[AR-GigabitEthernet0/0/0]ip address 10.11.12.13 24 #配置IP地址及子网掩码
[AR-GigabitEthernet0/0/0]ping 10.11.12.1 #检测连通性
PING 10.11.12.1: 56 data bytes, press CTRL_C to break
Reply from 10.11.12.1: bytes=56 Sequence=1 ttl=128 time=80 ms
Reply from 10.11.12.1: bytes=56 Sequence=2 ttl=128 time=10 ms
Reply from 10.11.12.1: bytes=56 Sequence=3 ttl=128 time=10 ms
Reply from 10.11.12.1: bytes=56 Sequence=4 ttl=128 time=10 ms
Reply from 10.11.12.1: bytes=56 Sequence=5 ttl=128 time=10 ms
--- 10.11.12.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/24/80 ms
[AR-GigabitEthernet0/0/0]quit #退出端口
[AR]interface GigabitEthernet 0/0/1 #进入端口0/0/1
[AR-GigabitEthernet0/0/1]ip address 192.168.1.253 24 #配置IP地址及子网掩码
[AR-GigabitEthernet0/0/1]quit #退出端口

2、配置交换机

The device is running!
system-view #进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname Switch #修改设备名称
[Switch]interface Vlanif 1 #进入vlanif 1接口(三层接口)
[Switch-Vlanif1]ip address 192.168.1.254 24 #配置IP地址及子网掩码
[Switch-Vlanif1]ping 192.168.1.253 #检测连通性
PING 192.168.1.253: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.253: bytes=56 Sequence=1 ttl=255 time=70 ms
Reply from 192.168.1.253: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 192.168.1.253: bytes=56 Sequence=3 ttl=255 time=40 ms
Reply from 192.168.1.253: bytes=56 Sequence=4 ttl=255 time=50 ms
Reply from 192.168.1.253: bytes=56 Sequence=5 ttl=255 time=40 ms
--- 192.168.1.253 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/46/70 ms
[Switch-Vlanif1]quit #退出vlanif接口
[Switch]ip route-static 0.0.0.0 0.0.0.0 192.168.1.253 #配置默认路由

3、路由器nat部分

[AR]dns server 114.114.114.114 #配置dns服务器地址
[AR]dns resolve #开启dns功能
[AR]acl 2001 #创建acl 2001
[AR-acl-basic-2001]rule permit source 192.168.1.0 0.0.0.255 #匹配允许的ip地址及长度
[AR-acl-basic-2001]quit #退出acl 2001
[AR]interface GigabitEthernet 0/0/0 #进入端口0/0/0
[AR-GigabitEthernet0/0/0]nat outbound 2001 #配置nat方向及匹配规则
[AR]ip route-static 0.0.0.0 0.0.0.0 10.11.12.1 #添加默认路由

4、PC检测是否可以访问网关及外网

查看PC地址及ping交换机网关

PC地址及ping网关

可以ping外网网关及baidu地址

#谢谢#

#华为##路由器#