大网数据广告活动
服务器运维问答

Override DNS entry when VPN connected without DNS server

· 52CE 我爱测

I have moved a server into Azure, the server is working perfectly however now I want to connect users to the server when they're at home using a VPN. I have setup the VPN in Azure and this is working correctly, I can access the s…

问题原文

原帖链接 · bendataclear · CC BY-SA 4.0

I have moved a server into Azure, the server is working perfectly however now I want to connect users to the server when they're at home using a VPN.

I have setup the VPN in Azure and this is working correctly, I can access the server using the local IP address (10.0.X.X) however there are multiple applications that are setup to use the public DNS entry (xxxx.[region].cloudapp.azure.com).

All the machines connect to the internet via a router using googles public DNS (8.8.8.8) but obviously when using the VPN, this resolves to the public IP not the private IP address.

I know I can create a DNS server and use this instead of Googles however this seems like overkill for this single re-direction.

Is there any way to redirect this single DNS entry when I connect to the VPN or via a batch script I can give to the users to use when they're at home?

已采纳解答

原帖链接 · batistuta09 · CC BY-SA 4.0

Friendly speaking it would be better to configure DNS according to "best practises".

But there is other way. I assume the endusers have Windows Client OS. Perform on each client (or with GPO/Automation):

1) Create a task in Windows Task scheduler

2) Set trigger to event 20267 (establishing VPN)

3) Set the following batch (modify IP and FQDN) as an action:

copy C:\Windows\System32\drivers\etc\hosts C:\Windows\System32\drivers\etc\hosts.bak /Y
echo "10.0.X.X  xxxx.[region].cloudapp.azure.com" >> C:\Windows\System32\drivers\etc\hosts 
ipconfig /flushdns

4) Create the second task in Windows Task scheduler

5) Set trigger to event 20268 (close VPN connection)

6) Set the following batch as an action to restore original configuration:

    copy C:\Windows\System32\drivers\etc\hosts.bak C:\Windows\System32\drivers\etc\hosts /Y
    ipconfig /flushdns

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-03-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。