config system interface edit "internal" set vdom "root" set allowaccess ping https ssh snmp http set type hard-switch set monitor-bandwidth enable set role lan next edit "proxyIn" set vdom "root" set ip 10.10.10.10 255.255.255.0 set allowaccess ping set role lan set interface "internal" set vlanid 10 next edit "proxyOut" set vdom "root" set ip 10.20.20.20 255.255.255.0 set allowaccess ping set role lan set interface "internal" set vlanid 20 next end
2.2.创建地址对象
创建代理机相关的地址对象,方便后面写防火墙策略和策略路由。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
config firewall address edit "proxyIn" set type iprange set associated-interface "proxyIn" set start-ip 10.10.10.11 set end-ip 10.10.10.11 next edit "proxyOut" set type iprange set associated-interface "proxyOut" set start-ip 10.20.20.21 set end-ip 10.20.20.21 next end
config firewall address edit "internalClient" set type iprange set comment "内网客户端设备(DHCP)" set associated-interface "internal" set start-ip 192.168.99.121 set end-ip 192.168.99.170 next end
config firewall address edit "ipdetect" set type fqdn set fqdn "ipdetect.arlxn.top" next end
2.4.创建策略路由
这一步创建策略路由,策略是将指定地址对象的流量发送到指定的网关上。
1 2 3 4 5 6 7 8 9 10
config router policy edit 1 set input-device "internal" set srcaddr "internalClient" set dstaddr "ipdetect" set gateway 10.10.10.11 set output-device "proxyIn" set status enable next end
2.5.创建防火墙策略(放行)
放行内网到代理机的流量
1 2 3 4 5 6 7 8 9 10 11 12
config firewall policy edit 199 set name "InternalSetting" set srcintf "internal" set dstintf "proxyIn" set action accept set srcaddr "internalClient" set dstaddr "proxyIn address" set schedule "always" set service "ALL" next end
放行代理机出网流量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
config firewall policy edit 198 set name "proxyOut" set srcintf "proxyOut" set dstintf "wan1" set action accept set srcaddr "proxyOut" set dstaddr "all" set schedule "always" set service "ALL" set nat enable set fixedport enable set comments "代理机上网" next end
我的所有DNS都走内网(内网有独立的DNS服务器),因此还需要放行代理机到内网DNS的流量
1 2 3 4 5 6 7 8 9 10 11 12 13
config firewall policy edit 197 set name "proxyToDNS" set srcintf "proxyOut" set dstintf "internal" set action accept set srcaddr "proxyOut" set dstaddr "DNServerAddr" set schedule "always" set service "DNS" set comments "代理机DNS" next end
放行从【普通客户端】经由【策略路由】指引到【代理机】的流量
1 2 3 4 5 6 7 8 9 10 11 12
config firewall policy edit 196 set name "internetThroughProxy" set srcintf "internal" set dstintf "proxyIn" set action accept set srcaddr "internalClient" set dstaddr "all" set schedule "always" set service "ALL" next end