生活的道路一旦选定,就要勇敢地走到底,决不回头。

首页 » 阅读时间 » 科技 » EdgeMax 端口策略路由配置

EdgeMax 端口策略路由配置

发布时间:2022年11月20日 修改时间:2024年05月15日 已有 63156 人围观

EdgeRouter 支援 端口策略 路由,即根据不同端口分配走不同的上网线路出口路由。


实验目的


网络环境为 2 条上网线路,在 EdgeRouter 中配置针对 80 端口流量走上网线路 1,其他非 80 端口数据走上网线路 2。


网络拓扑图



网络环境说明


  1. eth1 连接上网线路 1,上网线路 1 网关为 192.168.10.1/24,DNS 为 192.168.10.1
  2. eth2 连接上网线路 2,上网线路 2 网关为 192.168.20.1/24,DNS 为 192.168.20.1
  3. 配置 eth1/eth2 分别为 wan1 和 wan2,IP 地址分别配置为 192.168.10.100/24 和 192.168.20.200/24
  4. 配置 eth4 为 Lan,IP 地址分别配置为 172.18.1.1/24
  5. 配置 eth1/eth2 做 NAT
  6. 配置 eth4 做 DNS 转发接口

EdgeRouter 基础配置


1.配置 eth1/eth2 为 WAN1/WAN2,IP 地址分别配置为 192.168.10.100/24 和 192.168.20.200/24

2.分别配置 eth1/eth2 的默认路由网关为 192.168.10.1/24 和 192.168.20.1/24

3.分配配置 eth1/eth2 的上网线路 DNS 为 192.168.10.1/24 和 192.168.20.1/24

4.分别配置 eth1/eth2 做 NAT

5.配置 eth4 为 LAN,IP 地址分别配置为 172.18.1.1/24

6.配置 DHCP-LAN172.18.1.10-172.18.1.200

7.将 eth4 加入到 DNS 转发接口


EdgeRouter 配置端口策略路由


1.电脑连接 eth4 并获得 172.18.1.X/24 的 IP 地址,通过 ssh 访问 EdgeRouter 管理 IP172.18.1.1

2.输入 EdgeRouter 管理员账号密码登入,并输入 configure 进入配置模式

3.输入如下命令行配置 2 个子路由器表出口

set protocols static table 1 route 0.0.0.0/0 next-hop 192.168.10.1
set protocols static table 2 route 0.0.0.0/0 next-hop 192.168.20.1

4.输入如下命令配置端口 80 的流量走上网线路 1 即从 eth1-192.168.10.100 接口路由出口

set firewall modify out rule 10 description 'use table1 for 80'
set firewall modify out rule 10 protocol tcp
set firewall modify out rule 10 destination port 80
set firewall modify out rule 10 modify table 1

5.输入如下命令配置其它非 80 端口流量走上网线路 2 即从 eth2-192.168.20.200 接口路由出口

set firewall modify out rule 20 description 'everything except 80'
set firewall modify out rule 20 modify table 2

6.配置策略路由接口为 eth4.in 即 LAN.in 接口

set interfaces ethernet eth4 firewall in modify out

7.输入 commit 配置生效,并输入 save 保存配置

commit
save


LAN 客户端测试


1.通过浏览器访问 www.youku.com,也就是访问 youku 的 80 端口,该数据流量走 eth1 上网线路 1

2.通过浏览器访问 https://X.X.X.X:8443,也就是访问 X.X.X.X 的 8443 端口,该数据流量走 eth2 上网线路 2

3.先拔掉 eth1 的上网线路,再通过浏览器访问 www.youku.com,也就是访问 youku 的 80 端口,该数据流量走 eth2 上网线路 2