zoukankan      html  css  js  c++  java
  • CentOS 7 安装 dnsmasq 服务 实现内网DNS

    安装

    废话不多述,上来就安装

    yum install -y bind-utils dnsmasq
    

    配置

    [root@jenkins ~]# rpm -ql dnsmasq
    /etc/dbus-1/system.d/dnsmasq.conf
    /etc/dnsmasq.conf               # 主配置文件
    /etc/dnsmasq.d
    /usr/lib/systemd/system/dnsmasq.service
    /usr/sbin/dnsmasq               # 命令
    /usr/share/doc/dnsmasq-2.76
    /usr/share/doc/dnsmasq-2.76/CHANGELOG
    /usr/share/doc/dnsmasq-2.76/COPYING
    /usr/share/doc/dnsmasq-2.76/COPYING-v3
    /usr/share/doc/dnsmasq-2.76/DBus-interface
    /usr/share/doc/dnsmasq-2.76/FAQ
    /usr/share/doc/dnsmasq-2.76/doc.html
    /usr/share/doc/dnsmasq-2.76/setup.html
    /usr/share/man/man8/dnsmasq.8.gz
    /var/lib/dnsmasq
    

    修改配置如下

    [root@jenkins ~]# egrep -v '^#|^$' /etc/dnsmasq.conf
    port=53
    resolv-file=/etc/resolv.conf
    strict-order
    listen-address=192.168.1.122,127.0.0.1
    addn-hosts=/etc/dnsmasq_hosts
    cache-size=150
    conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig
    

    创建 /etc/dnsmasq_hosts 解析文件,并写入配置

    [root@jenkins ~]# cat /etc/dnsmasq_hosts
    192.168.1.90 vip01 vip01.k8s.com
    

    服务管理

    # 启动
    systemctl start dnsmasq
    
    # 关闭
    systemctl stop dnsmasq
    
    # 开机自启
    systemctl enable dnsmasq
    
    

    测试解析

    [root@node01 ~]# dig vip01.k8s.com @192.168.1.122
    
    ; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> vip01.k8s.com @192.168.1.122
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53340
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 3
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 4096
    ;; QUESTION SECTION:
    ;vip01.k8s.com.			IN	A
    
    ;; ANSWER SECTION:
    vip01.k8s.com.		86400	IN	A	192.168.1.90
    
    ;; AUTHORITY SECTION:
    k8s.com.		86400	IN	NS	k8s.com.
    
    ;; ADDITIONAL SECTION:
    k8s.com.		86400	IN	A	127.0.0.1
    k8s.com.		86400	IN	AAAA	::1
    
    ;; Query time: 0 msec
    ;; SERVER: 192.168.1.122#53(192.168.1.122)
    ;; WHEN: Wed Nov 06 22:12:22 CST 2019
    ;; MSG SIZE  rcvd: 116
    
  • 相关阅读:
    Exchange 2016与国内版O365混合部署(1):过程总览
    Office365与本地Exchange混合部署之邮件流介绍详情
    清理Exchange 2013和2016的Log文件(精华)
    Exchange2016日志路径
    C:/inetpub/logs/logfile/路径详解
    使用VMwareVCenterConverter迁移到虚拟机(p2v)
    WindowsServer安全基线
    利用WSUS部署更新程序
    Storefront与NetScaler的集成配置
    运维技巧(13):Exchange证书申请导入
  • 原文地址:https://www.cnblogs.com/winstom/p/11809066.html
Copyright © 2011-2022 走看看