如何创建自己的自定义主机文件?
由于某些特定原因,我不想编辑/etc/hosts
文件,这就是为什么我需要在假设~/hosts
创建我自己的主机文件并将其用于所有IP到HOSTNAME映射以及系统的/etc/hosts
文件。 我怎么能这样做?
使用环境变量HOSTALIASES
:
-
定义环境变量
HOSTALIASES
export HOSTALIASES=~/.hosts
-
创建私有
hosts
文件并添加测试条目echo 'myprivategoogle www.google.com' > ~/.hosts
-
开始测试
curl myprivategoogle
你没有在
~/.hosts
输入curl: (6) Could not resolve host: myprivategoogle
与您的条目
302 Moved 302 Moved
The document has moved here.