logo
tt's Note
  • 运维
    • 数据库
    • linux
    • vpn
    • 日志
    • 中间件
    • 服务
    • 监控
    • shell
    • windows
    • 语言
    • 云服务
    • 其他
  • 开发
    • 工具
  • 软件
    • 浏览器
    • 多端
    • win
    • mac
    • 网站
  • 项目
    • 效率工具
    • 兴趣
  • 脚本
    • jenkins
    服务概览
    ansible
    chrony时间服务器
    dnsmasq
    ffmpeg
    frp
    ftp
    gitea
    gitlab
    jenkins
    lsyncd
    minio(私有化oss)
    nacos
    nexus3(私有仓库)
    ossftp
    redmine
    registry(docker私有仓库)
    saltstack
    svn
    上一页chrony时间服务器下一页ffmpeg

    #dnsmasq

    dns和dhcp的轻量服务端

    配置文档

    开源地址

    #启动

    #!/bin/bash
    
    #############
    # dnsmasq
    ###########
    
    docker stop dnsmasq
    docker rm dnsmasq
    docker run -d \
    --restart=always \
    --net host \
    --name dnsmasq \
    --privileged \
    -e TZ=Asia/Shanghai \
    -e HTTP_USER=muen \
    -e HTTP_PASS=ePDWG22CKmnD2Waa \
    -e PORT=5380 \
    -v $(pwd)/config/dnsmasq.conf:/etc/dnsmasq.conf:rw \
    -v $(pwd)/dhcp-hosts.d/:/etc/dnsmasq/dhcp-hosts.d/ \
    jpillora/dnsmasq:1.1.0
    

    #配置

    # dnsmasq config, for a complete example, see:
    #  http://oss.segetech.com/intra/srv/dnsmasq.conf
    # 配置文档
    # https://e-mailky.github.io/2018-07-14-dnsmasq
    # log all dns queries
    log-queries
    # dont use hosts nameservers
    no-resolv
    # use cloudflare as default nameservers, prefer 1^4
    server=223.5.5.5
    server=8.8.8.8
    strict-order
    # serve all .company queries using a specific nameserver
    server=/company/10.0.0.1
    # explicitly define host-ip mappings
    address=/myhost.company/10.0.0.2
    
    # 国内指定DNS
    # server=/cn/114.114.114.114
    # server=/taobao.com/114.114.114.114
    # server=/taobaocdn.com/114.114.114.114
    # 国外指定DNS
    # server=/google.com/223.5.5.5
    
    
    ######################## dhcp ####################################
    
    # dhcp逻辑文件, 修改会自动重载
    dhcp-hostsdir=/etc/dnsmasq/dhcp-hosts.d
    
    # Dynamic range of IPs to make available to LAN pc
    dhcp-range=10.32.9.2,10.32.9.254,255.255.240.0,12h
    
    # If you’d like to have dnsmasq assign static IPs, bind the LAN computer's
    # NIC MAC address:
    dhcp-host=aa:bb:cc:dd:ee:ff,192.168.111.50
    
    Tip

    由于配置中配置了dhcp-hostsdir, dhcp的配置可以放在/etc/dnsmasq/dhcp-hosts.d, 服务会自动重载

    00:66:77:88:99:AA,192.168.1.101
    00:66:77:88:99:AA,host2,192.168.1.101,24h