当前位置:网站首页>/etc/resolv.conf的作用
/etc/resolv.conf的作用
2022-07-31 23:15:00 【larance】
背景故事:
我们是否有过这样的经历:在用浏览器上网的时候上不去,而qq就可以登上去。为什么?dns出了问题,其中之一的办法就是可以通过配置/etc/resolv.conf来解决这个问题。
是什么?
/etc/resolv.conf它是DNS客户机配置文件,用于设置DNS服务器的IP地址及DNS域名,还包含了主机的域名搜索顺序。该文件是由域名解析器(resolver,一个根据主机名解析IP地址的库)使用的配置文件。
nameserver #定义DNS服务器的IP地址
domain #定义本地域名
search #定义域名的搜索列表
sortlist #对返回的域名进行排序
/etc/resolv.conf的一个示例:
domain test.com
search www.test.com test.com
nameserver 202.96.128.86
nameserver 202.96.128.166
最主要是nameserver关键字,如果没指定nameserver就找不到DNS服务器,其它关键字是可选的。
nameserver ——表示解析域名时使用该地址指定的主机为域名服务器。其中域名服务器是按照文件中出现的顺序来查询的,且只有当第一个nameserver没有反应时才查询下面的nameserver。
domain 声明主机的域名。很多程序用到它,如邮件系统;当为没有域名的主机进行DNS查询时,也要用到。如果没有域名,主机名将被使用,删除所有在第一个点( .)前面的内容。
search 它的多个参数指明域名查询顺序。当要查询没有域名的主机,主机将在由search声明的域中分别查找。
domain和search不能共存;如果同时存在,后面出现的将会被使用。
sortlist 允许将得到域名结果进行特定的排序。它的参数为网络/掩码对,允许任意的排列顺序
优先级:dns缓存>hosts>dns服务
DNS解析的步骤:
1. 查找/etc/hosts
2. 根据nameserver查找域名
3. 如果在nameserver查找不到域名就进行search补全,重新走1~2步
最近遇到 wget: unable to resolve host address `******'
解决方法: vim /etc/resolv.conf
添加 nameserver 114.114.114.114
通常可以配置的 ip 有:
114.114.114.114
119.29.29.29
223.5.5.5
边栏推荐
- 手写一个简单的web服务器(B/S架构)
- 程序进程和线程(线程的并发与并行)以及线程的基本创建和使用
- EntityFramework保存到SQLServer 小数精度丢失
- "APIO2010" Patrol Problem Solution
- How to import a Golang external package and use it?
- LeetCode 第 304 场周赛
- 【FPGA教程案例43】图像案例3——通过verilog实现图像sobel边缘提取,通过MATLAB进行辅助验证
- 面试题:实现死锁
- SQL注入 Less42(POST型堆叠注入)
- I don't know what to do with sync issues
猜你喜欢
随机推荐
【ACM】2022.7.31训练赛
基于simulink的Active anti-islanding-AFD主动反孤岛模型仿真
The latest masterpiece!Alibaba just released the interview reference guide (Taishan version), I just brushed it for 29 days
Judging decimal points and rounding of decimal operations in Golang
ECCV 2022 Huake & ETH propose OSFormer, the first one-stage Transformer framework for camouflaging instance segmentation!The code is open source!...
hboot与recovery、boot.img、system.img
In Golang go-redis cluster mode, new connections are constantly created, and the problem of decreased efficiency is solved
面试题:实现死锁
flowable workflow all business concepts
How to identify fake reptiles?
Go mode tidy reports an error go warning “all” matched no packages
Golang - from entry to abandonment
消息队列消息存储设计(架构实战营 模块八作业)
Quick Start Tutorial for flyway
Write a database document management tool based on WPF repeating the wheel (1)
[QNX Hypervisor 2.2用户手册]9.16 system
Shell common scripts: Nexus batch upload local warehouse enhanced version script (strongly recommended)
Difference Between Stateless and Stateful
Audio alignment using cross-correlation
SQL injection Less42 (POST type stack injection)