ubuntu 通过修改 /etc/hosts 强制捆绑域名和IP地址

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wuzhong8809/article/details/84061323

通过修改 /etc/hosts 强制捆绑域名和IP地址

下面通过将  abc.com 的IP指定为 127.0.0.1 为例:

一、打开 /etc/hosts 文件,在其中添加如下一行:

127.0.0.1       abc.com
保存退出。

二、重启网络模块

sudo /etc/init.d/networking restart

三、验证

>ping abc.com
PING abc.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.092 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.084 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.077 ms
 

猜你喜欢

转载自blog.csdn.net/wuzhong8809/article/details/84061323
今日推荐