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了。

  • 相关阅读:
    跨域访问(nginx)
    mybatis中<set>标签和<trim prefix="set" suffixOverrides=",">
    如何在Oracle中复制表结构和表数据
    Oracle删除重复数据
    Oracle中删除表
    Oracle中on和where的区别
    Java实体类中的类型对应mybatis的jdbcType
    Java 枚举(enum) 常见用法
    关于JS 事件冒泡和onclick,click,on()事件触发顺序
    浅析 SpringMVC 的@PathVariable 和 @RequestParam 和 @RequestBody注解
  • 原文地址:https://www.cnblogs.com/hugetong/p/6548391.html
Copyright © 2011-2022 走看看