手把手教你使用 Raspberry - DNS Server

RPI DNS Server

将Raspberry配置成DNS server

  • Install the dnsmasq

    $ sudo apt-get install dnsmasq
  • Configure the /etc/dnsmasq.conf,add the parameters:

    resolv-file=/etc/resolv.dnsmasq
    
    #strict-order
    
    cache-size=1500
    listen-address=127.0.0.1,192.168.52.1
    address=/myapp.com/192.168.52.1
  • Edit the /etc/udhcpd.conf and change the line,

    opt     dns    8.8.8.8 4.2.2.2 #192.168.10.2 192.168.10.10

    to

    opt     dns     192.168.52.1
    
  • Configure the network

    allow-hotplug wlan0
    iface wlan0 inet static
    address 192.168.52.1
    netmask 255.255.255.0
    gateway 192.168.52.1
    network 192.168.52.0
    broadcast 192.168.52.255
    dns-nameservers 192.168.52.1
    
    up iptables-restore < /etc/iptables.ipv4.nat
  • /etc/resolv.conf,由于此文件为系统启动重新设置文件,需要添加以下文件:

    • /etc 目录下新增resolv.conf.head,内容如下:
    
    # Google DNS
    
    
    #nameserver 8.8.8.8
    
    
    
    #OpenDns Servers
    
    
    #nameserver 208.67.222.222  
    
    
    #nameserver 208.67.220.220
    
    
    nameserver 192.168.52.1
  • Restart service

    sudo service dnsmasq restart

    此时,访问myapp.com 就可以解析到 192.168.52.1
    可通过 ping myapp.com进行测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值