zoukankan      html  css  js  c++  java
  • [archlinux][daily] 自建DNS服务器 / 建立本地DNS cache / 使用dnsmasq加速上网

    新公司,上网超慢,DNS竟然是远程地址,终于找到机会学习一下dnsmasq了。

    update@20170516: 上网慢是因为分给我的IP有限流策略,其实远端DNS并不会造成感受上的上网慢。

    参考:https://wiki.archlinux.org/index.php/Dnsmasq

    安装:

    /home/tong [tong@T7] [14:30]
    > pacman -Q |grep dnsmasq
    dnsmasq 2.76-4

    配置: 监听在本地,上游DNS server 手配在 resolv-dnsmasq.conf 中。

    /home/tong [tong@T7] [14:25]
    > cat /etc/dnsmasq.conf| grep -v '^#'
    resolv-file=/etc/resolv-dnsmasq.conf
    listen-address=127.0.0.1
    /home/tong/VM [tong@T7] [16:24]
    > cat /etc/resolv-dnsmasq.conf
    nameserver 114.114.114.114
    nameserver 8.8.8.8

    启动:

    /home/tong [tong@T7] [14:32]
    > systemctl start dnsmasq.service

    网络设置时,有哪些改变?

    在配置网络时,使用netctl,它会调用resolvconf命令配置 /etc/resolv.conf 文件,我猜。

    所以,修改配置,让resolvconf在resolv.conf 中只使用本地dns就行了,如下:

    /home/tong [tong@T7] [14:33]
    > cat /etc/resolvconf.conf
    # Configuration for resolvconf(8)
    # See resolvconf.conf(5) for details
    
    resolv_conf=/etc/resolv.conf
    # If you run a local name server, you should uncomment the below line and
    # configure your subscribers configuration files below.
    name_servers=127.0.0.1

    然后,在配置静态IP时,netctl配置文件中的DNS选项,并不会影响resolv.conf文件。

    dhcp时,好像要hook dhcpcd,没看,以后再说。

    -------------------  update@21070516  -------------------

    除了本机,虚拟机也想用。而且希望多个虚拟机和主机之间可以通过hostname相互访问。

    很简单,只需要改如下参数,重启服务就可以了。

    /home/tong/VM/kingkong-centos6.3 [tong@T7] [20:17]
    > cat /etc/dnsmasq.conf |grep ^listen
    listen-address=127.0.0.1,192.168.7.1

    TODO: 于是问题来了,能不能在众多虚拟机之间启用dhcp呢,然后使用hostname相互访问,在也不要关心IP了,在也不要手配静态IP了。

  • 相关阅读:
    C语言与汇编的嵌入式编程:统计字符串中各字符出现的次数
    一个汇编小demo
    C语言与汇编的嵌入式编程:求100以内素数
    TCP网络调试助手上提示错误:“1035 未知错误”的有效解决方法,本人实测确实可行
    一个支持国密SM2/SM3/SM4/SM9/ZUC/SSL的密码工具箱
    DRM(device resource management)介绍
    TODO
    pinctrl(1)——pinctrl子系统的使用
    GPIO使用总结
    Gerrit使用技巧
  • 原文地址:https://www.cnblogs.com/hugetong/p/6548391.html
Copyright © 2011-2022 走看看