主机名解析而不修改hosts文件 [英] Host name resolution without modifying the hosts file

查看:157
本文介绍了主机名解析而不修改hosts文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图弄清楚如果有一种方法可以让主机名解析为某个IP而无需DNS或主机文件修改。

I'm trying to figure out how if there's a way to make a hostname resolve to a certain IP without DNS or host file modification.

使用C#,我我正在从客户端向服务器发出请求,但我必须在请求中使用主机名,以便证书可以正确地对请求进行身份验证。但是,我的程序是在没有管理员权限的情况下运行的,因此我无法修改主机文件。我有正确的IP和主机名,还有其他方法可以让计算机将主机名解析为IP吗?

Using C#, I'm making a request from client to server, but I have to use the hostname in the request so that the certificates will properly authenticate the request. However, my program is meant to run without admin rights, so I can't modify the host file. I have the correct IP and the host name, is there any other way to make the computer resolve the host name to the IP?

推荐答案

<看起来最简单的解决方法是创建一个具有修改主机文件权限的服务,然后从主程序调用该服务。该服务运行单个命令并退出。由于服务可以具有提升状态,因此您基本上可以将管理权限封装在标准用户程序中。

It looks like the simplest way to solve this is to create a service with the rights to modify the host file, then invoke that service from the main program. The service runs a single command and exits. Since a service can have elevated status, you can essentially encapsulate admin rights inside a standard user program.

这篇关于主机名解析而不修改hosts文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆