USG6300E 防火墙DNS 透明代理 指定域名解析为特定IP

2024-07-23 210 0

场景:外部网络依旧走公网解析,内部网络优先走指定内网IP

事因:公司原使用20M极速线路迁移后固定IP变化了,原备案开通的端口(80,443,8080)默认被禁用,重新备案需要一段时间。暂时过渡,将解析到云服务器,但上传/下载大文件很慢,直接挤爆20M带宽(若没做限流的话还会导致丢包、延迟高),用户体验很差。
办公网络没有部署内网DNS服务器,防火墙DHCP分配的DNS服务器为防火墙IP,所以直接USG6300防火墙做DNS解析配置, 优先走内网IP。

云服务器已做Nginx转发 非80、443、8080端口

server {
    listen 80;
    listen 443;
    server_name cloud.sundayhk.com
    index  index.html index.htm;

    ssl on;
    ssl_certificate      /data/ssl/acme/sundayhk.com.pem;
    ssl_certificate_key  /data/ssl/acme/sundayhk.com.key;
    include other/ssl.conf;

    location / {
        proxy_pass http://183.111.111.111:8878;
        proxy_set_header Host cloud.sundayhk.com;
        add_header Cache-Control no-store;
        add_header Pragma no-cache;
    }

    access_log /data/logs/nginx/cloud.sundayhk.com sunday;
}

公网DNS解析

C:\Users\Administrator>ping -c 1 cloud.sundayhk.com

正在 Ping cloud.sundayhk.com [183.111.111.111] 具有 32 字节的数据:
来自 183.111.111.111 的回复: 字节=32 时间=6ms TTL=50

USG防火墙 DNS配置

1、首先在usg上配置ip host指定cloud.sundayhk.com为特定ip

    ip host cloud.sundayhk.com 192.168.10.11

2、开启dns解析和dns代理功能

    dns resolve
    dns server 119.29.29.29
    dns proxy enable

3、若开启DNS透明代理,则需要排除这个指定域名

    dns transparent-proxy enable
    dns-transparent-policy
    dns transparent-proxy exclude domain cloud.sundayhk.com server preferred 192.168.10.1

192.168.10.1 为防火墙IP

4、客户端刷新DNS

C:\Users\Administrator>ipconfig/flushdns
Windows IP 配置
已成功刷新 DNS 解析缓存。

C:\Users\Administrator>ping -c 1 cloud.sundayhk.com
正在 Ping cloud.sundayhk.com [192.168.10.11] 具有 32 字节的数据:
来自 192.168.10.11 的回复: 字节=32 时间<1ms TTL=64

https://forum.huawei.com/enterprise/zh/thread/725126353747066880

相关文章

nextcloud preview-generate 报错文件无权限解决
tcpdump 抓包使用小结
Linux Tcpdump抓包
Ubuntu 18 SSH禁用密码登陆失效
Ubuntu 18.04 修复重启sysctl 失效
grep 批量查询中文文件名

发布评论