Ubuntu 20.04 修改hosts文件和刷新DNS缓存

1、修改hosts文件,在终端输入

sudo vi /etc/hosts

在末尾加入你要添加的IP地址和域名,比如

# The following lines are desirable for IPv6 capable hosts
::1     localhost       ip6-localhost   ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
8.8.8.8 XXXXXXXX  XXXXXXXX
127.0.0.1 localhost  localhost
140.82.112.4 github.com
185.199.108.153 assets-cdn.github.com
185.199.109.153 assets-cdn.github.com
185.199.110.153 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com
199.232.69.194 fastly.net
~                                                                                                                                                                   
~                                                                                                                                                                   
~                                                                                                                                                                    
~                                                                                                                                                                   
"/etc/hosts" 14L, 422C

(vi的基本用法是按i改成修改模式,添加完内容以后按ESC,然后按两次ZZ退出vi)

2、刷新DNS缓存

sudo systemd-resolve --flush-caches

Caleb
Caleb管理员

上一篇:Ubuntu Linux中缺少依赖导致的软件安装失败
下一篇:在Ubuntu20.04安装Odoo14

留言评论

暂无留言
请先 登录 再评论,若不是会员请先 注册
取消
扫码支持