上次从郝同学那里得来一个叫dnsmasq的好东东。兴奋的设置好了之后,dig一下,看着0ms的dns相应时间,真的很爽哦。
可是用着用着,发现上不了网了。域名无法解析。查看一下
cat /etc/resolv.conf
# Generated by dhcpcd
# /etc/resolv.conf.head can replace this line
nameserver 192.168.1.1
# /etc/resolv.conf.tail can replace this line
发现不是当初设置的127.0.0.1,而是被dhcpcd给覆盖了。
怒!
上网搜搜看,有人chattr +i 来解决,我觉得那样过于血腥,不是我们这些文明人该做的事。
既然是dhcpcd搞的鬼,找它这个肇事者应该没错。
我呼唤了另一个男人来做刽子手,严刑拷打之下,dhcpcd不再嘴硬,全招了。
man dhcpcd.conf
以下是供词节选
nohook
Don't run this hook . Matches full name, or prefixed with
2 numbers optionally ending with .sh.
So to stop dhcpcd from touching your DNS or MTU settings you
would do:-
nohook resolv.conf, mtu
秘籍:用”/“可以搜索文档中的关键词,比如"resolv.conf"
招了之后就好办了,修改/etc/dhcpcd.conf
nohook 那行后面加上一个resolv.conf
再重启,它就乖乖的了。