1 主机名配置

主机hd1配置(后面配置为名字服务器)

[grid_hd@hd1 Desktop]$ cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=hd1.asn.cn #主机名为hd1.asn.cn (asn.cn为搜索域)

[grid_hd@hd1 Desktop]$ cat /etc/hosts

127.0.0.1     localhost     localhost.localdomain

客户机hd2配置:

[grid_hd@hd2 Desktop]$ cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=hd2.asn.cn

[grid_hd@hd2 Desktop]$ cat /etc/hosts

127.0.0.1     localhost     localhost.localdomain

客户机hd3配置:

[grid_hd@hd3 Desktop]$ hostname

hd3.asn.cn

[grid_hd@hd3 Desktop]$ cat /etc/hosts

127.0.0.1    localhost     localhost.localdomain

2 名字服务配置

dnsmasq

[grid_hd@hd1 Desktop]$ sudo find / -name *dnsmasq*

/var/lock/subsys/dnsmasq

/var/run/dnsmasq.pid #进程PID文件

/var/lib/dnsmasq

/etc/dnsmasq.d ##放入该目录的文件将作为配置文件自动加载

/etc/dnsmasq ##自己创建的目录,用于存放上游名字服务列表文件resolv.conf和主机名到IP的映射文件hosts

/etc/dbus-1/system.d/dnsmasq.conf

/etc/selinux/targeted/modules/active/modules/dnsmasq.pp

/etc/dnsmasq.conf ##dnsmasq的主配置文件

/etc/rc.d/rc0.d/K50dnsmasq ##指向脚本文件/etc/rc.d/init.d/dmsmasq的软连接

/etc/rc.d/rc1.d/K50dnsmasq

/etc/rc.d/rc2.d/K50dnsmasq

/etc/rc.d/rc3.d/K50dnsmasq

/etc/rc.d/rc4.d/K50dnsmasq

/etc/rc.d/rc5.d/K50dnsmasq

/etc/rc.d/rc6.d/K50dnsmasq

/etc/rc.d/init.d/dnsmasq ##dnsmasq的启停控制Shell脚本文件{start|stop|restart|reload|condrestart|status}

/usr/sbin/dnsmasq ##dnsmasq服务程序二进制文件

[grid_hd@hd1 ~]$ ll /etc/rc.d/rc5.d/K50dnsmasq

lrwxrwxrwx. 1 root root 17 Jul 18 21:11 /etc/rc.d/rc5.d/K50dnsmasq -> ../init.d/dnsmasq ##指向脚本文件/etc/rc.d/init.d/dmsmasq

启动脚本文件/etc/rc.d/init.d/dnsmasq

#!/bin/sh

#

# Startup script for the DNS caching server

#

# chkconfig: - 49 50

# description: This script starts your DNS caching server 该脚本启动你的DNS缓存服务

# processname: dnsmasq

# pidfile: /var/run/dnsmasq.pid

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

dnsmasq=/usr/sbin/dnsmasq #定义dnsmasq变量

DOMAIN_SUFFIX=`dnsdomainname`

if [ ! -z "${DOMAIN_SUFFIX}" ]; then

OPTIONS="-s $DOMAIN_SUFFIX" #定义OPTIONS变量

fi

RETVAL=0 #定义RETVAL变量

PIDFILE="/var/run/dnsmasq.pid" #定义PIDFILE变量

# See how we were called.

case "$1" in #$0为程序名,$1代表第一参数

#如果输入参数是start

start)

if [ $UID -ne 0 ] ; then

echo "User has insufficient privilege."

fi

echo -n "Starting dnsmasq: "

daemon $dnsmasq $OPTIONS

RETVAL=$?

echo

[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dnsmasq

;;

#如果输入参数是stop

stop)

if test "x`pidfileofproc dnsmasq`" != x; then

echo -n "Shutting down dnsmasq: "

killproc dnsmasq

fi

RETVAL=$?

echo

[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dnsmasq $PIDFILE

;;

status)

status -p $PIDFILE dnsmasq

RETVAL=$?

;;

reload)

if test "x`pidfileofproc dnsmasq`" != x; then

echo -n "Reloading dnsmasq: "

killproc dnsmasq -HUP

fi

RETVAL=$?

echo

;;

force-reload)

# new configuration takes effect only after restart

$0 stop

$0 start

RETVAL=$?

;;

restart)

$0 stop

$0 start

RETVAL=$?

;;

condrestart)

if test "x`pidfileofproc dnsmasq`" != x; then

$0 stop

$0 start

RETVAL=$?

fi

;;

*)

echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"

exit 2

esac #

exit $RETVAL

/etc

├── dnsmasq

│      ├── hosts

│      ├── resolv.conf

├── dnsmasq.conf

├── dnsmasq.d

配置

/etc/dnsmasq.conf

[grid_hd@hd1 ~]$ cat /etc/dnsmasq.conf

# Change this line if you want dns to get its upstream servers from somewhere other that /etc/resolv.conf

# 如果你想让dns从某个地方(而不是/etc/resolv.conf)获得上游服务

resolv-file=/etc/dnsmasq/resolv.conf ##从/etc/dnsmasq/resolv.conf文件中获得上游DNS服务的IP地址

# By default, dnsmasq will send queries to any of the upstream servers it knows about

# 默认dnsmasq会把查询请求发送到它知道的任意一个上游DNS服务器

# and tries to favour servers to are known to be up.

# Uncommenting this forces dnsmasq to try each query with each server strictly in the order they appear in /etc/resolv.conf

# 解注该行,强制dnsmasq严格以/etc/resolv.conf文件中每个服务的出现顺序尝试查询

strict-order

# Or which to listen on by address (remember to include 127.0.0.1 if you use this.)

listen-address=192.168.145.151,127.0.0.1

# For debugging purposes, log each DNS query as it passes through dnsmasq.

log-queries

# If you don't want dnsmasq to read /etc/hosts, uncomment the following line.

no-hosts

# or if you want it to read another file, as well as /etc/hosts, use this.

addn-hosts=/etc/dnsmasq/hosts

/etc/dnsmasq/resolv.conf 配置上游名字服务的IP地址

[grid_hd@hd1 ~]$ cat /etc/dnsmasq/resolv.conf

nameserver    192.168.145.2

nameserver    8.8.8.8

nameserver    8.8.4.4

/etc/dnsmasq/hosts 自定义的域名(主机名,名字)到IP映射

[grid_hd@hd1 ~]$ cat /etc/dnsmasq/hosts

192.168.145.151        hd1.asn.cn    hd1

192.168.145.152        hd2.asn.cn    hd2

192.168.145.153        hd3.asn.cn    hd3

查看/etc/resolv.conf

[grid_hd@hd1 ~]$ cat /etc/resolv.conf

# Generated by NetworkManager

search asn.cn

nameserver 127.0.0.1 ##遇到不认识的名字,首先本地解释,然后再找上游服务器

重启

[grid_hd@hd1 ~]$ sudo service dnsmasq restart

Shutting down dnsmasq: [ OK ]

Starting dnsmasq: [ OK ]

设置开机自启

[grid_hd@hd1 ~]$ sudo chkconfig --list dnsmasq

dnsmasq     0:off    1:off    2:off    3:off    4:off    5:off    6:off

[grid_hd@hd1 ~]$ sudo chkconfig dnsmasq on

[grid_hd@hd1 ~]$ sudo chkconfig --list dnsmasq

dnsmasq     0:off    1:off    2:on    3:on    4:on    5:on    6:off

本机测试

[grid_hd@hd1 ~]$ dig archive.cloudera.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.2 <<>> archive.cloudera.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56484

;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:

;archive.cloudera.com.        IN    A

;; ANSWER SECTION:

archive.cloudera.com.    5    IN    CNAME    j.global-ssl.fastly.net.

j.global-ssl.fastly.net. 5    IN    A    199.27.79.68

;; AUTHORITY SECTION:

fastly.net.        5    IN    NS    ns3.p04.dynect.net.

fastly.net.        5    IN    NS    ns4.p04.dynect.net.

fastly.net.        5    IN    NS    ns1.p04.dynect.net.

fastly.net.        5    IN    NS    ns2.p04.dynect.net.

;; ADDITIONAL SECTION:

ns1.p04.dynect.net.    5    IN    A    208.78.70.4

ns2.p04.dynect.net.    5    IN    A    204.13.250.4

ns3.p04.dynect.net.    5    IN    A    208.78.71.4

ns4.p04.dynect.net.    5    IN    A    204.13.251.4

;; Query time: 337 msec

;; SERVER: 127.0.0.1#53(127.0.0.1)

;; WHEN: Sun Aug 9 22:24:29 2015

;; MSG SIZE rcvd: 238

[grid_hd@hd1 ~]$ dig archive.cloudera.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.2 <<>> archive.cloudera.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24829

;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:

;archive.cloudera.com.        IN    A

;; ANSWER SECTION:

archive.cloudera.com.    5    IN    CNAME    j.global-ssl.fastly.net.

j.global-ssl.fastly.net. 5    IN    A    199.27.79.68

;; AUTHORITY SECTION:

fastly.net.        5    IN    NS    ns4.p04.dynect.net.

fastly.net.        5    IN    NS    ns1.p04.dynect.net.

fastly.net.        5    IN    NS    ns2.p04.dynect.net.

fastly.net.        5    IN    NS    ns3.p04.dynect.net.

;; ADDITIONAL SECTION:

ns1.p04.dynect.net.    5    IN    A    208.78.70.4

ns2.p04.dynect.net.    5    IN    A    204.13.250.4

ns3.p04.dynect.net.    5    IN    A    208.78.71.4

ns4.p04.dynect.net.    5    IN    A    204.13.251.4

;; Query time: 5 msec

;; SERVER: 127.0.0.1#53(127.0.0.1) ##从本地获得解释

;; WHEN: Sun Aug 9 22:24:38 2015

;; MSG SIZE rcvd: 238

客户机hd2配置、使用

[grid_hd@hd2 Desktop]$ dig archive.cloudera.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.2 <<>> archive.cloudera.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43528

;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:

;archive.cloudera.com.        IN    A

;; ANSWER SECTION:

archive.cloudera.com.    5    IN    CNAME    j.global-ssl.fastly.net.

j.global-ssl.fastly.net. 5    IN    A    23.235.47.68

;; AUTHORITY SECTION:

fastly.net.        5    IN    NS    ns4.p04.dynect.net.

fastly.net.        5    IN    NS    ns3.p04.dynect.net.

fastly.net.        5    IN    NS    ns2.p04.dynect.net.

fastly.net.        5    IN    NS    ns1.p04.dynect.net.

;; ADDITIONAL SECTION:

ns1.p04.dynect.net.    5    IN    A    208.78.70.4

ns2.p04.dynect.net.    5    IN    A    204.13.250.4

ns3.p04.dynect.net.    5    IN    A    208.78.71.4

ns4.p04.dynect.net.    5    IN    A    204.13.251.4

;; Query time: 192 msec

;; SERVER: 192.168.145.151#53(192.168.145.151) ##从配置的主机hd1获得解释

;; WHEN: Sun Aug 9 22:30:14 2015

;; MSG SIZE rcvd: 238

centos6 名字服务dnsmasq配置的更多相关文章

  1. centos6.6-------DHCP服务配置

    一.为一个单一的网段提供地址服务 软件包:  dhcp配置文件:  /etc/dhcp/dhcpd.conf租约文件:     /var/lib/dhcpd/dhcpd.leases监听端口:     ...

  2. DNSmasq – 配置DNS和DHCP

    DNSmasq是一个小巧且方便地用于配置DNS和DHCP的工具,适用于小型网络.它提供了DNS功能和可选择的DHCP功能可以取代dhcpd(DHCPD服务配置)和bind等服务,配置起来更简单,更适用 ...

  3. ArcGIS Server 10 Java 版的Rest服务手动配置方法

    Java版的Manager中发布的服务默认只发布了该服务的SOAP接口,而REST接口需要用户在信息服务器,如Tomcat. Apache.WebLogic等中手工配置.由于在Java版的Server ...

  4. Linux(CentOs6.3)网络配置

    新装好的虚拟机往往还无法连接网络,本文描述了如何在CentOs6.3系统上配置网络信息 1.windows系统下快捷键windows+r,输入cmd并确定,打开黑窗口 2.黑窗口中输入ipconfig ...

  5. CentOS6.9快速安装配置svn

    CentOS6.9快速安装配置svn 环境介绍: 操作系统:CentOS release 6.9 (Final)192.168.65.130 (svn服务器)192.168.65.129 (svn客户 ...

  6. OpenStack-Ocata版+CentOS7.6 云平台环境搭建 —7.网络服务Neutron配置

    网络服务Neutron本章节结束如何安装并配置网络服务(neutron)采用:ref:`provider networks <network1>`或:ref:`self-service n ...

  7. centos6启动服务说明

    centos6启动服务说明 阅读目录 centos6.9最小化安装下的启动服务 其他服务(仅供参考,持续更新) 此表转自:参考1.参考2.另有多处补充及纠正. 1. centos6.9最小化安装下的启 ...

  8. CentOS7下RabbitMQ服务安装配置

    参考文档: CentOS7下RabbitMQ服务安装配置 http://www.linuxidc.com/Linux/2016-03/129557.htm 在linux下安装配置rabbitMQ详细教 ...

  9. Docker关联使用的一些工具:Clip名字服务(转载)

    Clip名字服务 Clip(http://blog.puppeter.com/read.php?7)是一个名字服务C/S架构,它将传统的IP管理维度替换为名字服务即有意义可记忆的String.Clip ...

随机推荐

  1. 【洛谷P3131】 【USACO16JAN】子共七

    P3131 [USACO16JAN]子共七Subsequences Summing to Sevens 题目描述 Farmer John's cows are standing in a row, a ...

  2. Node.js调试技巧

    1. console.log 跟前端调试相同,通过一步步打印相关变量进行代码调试 2. 使用Node.js内置的调试器 通过node debug xxx.js来进行调试: [root@~/wade/n ...

  3. npm ci命令比npm installer命令快2至10倍

    npm 5.7.1的发布给我们带了一系列新的功能. 其中我最喜欢的就是npm ci命令了. npm ci命令 1.npm ci命令只根据lock-file去下载node_modules. 如果你的pa ...

  4. ML面试1000题系列(41-50)

    本文总结ML面试常见的问题集 转载来源:https://blog.csdn.net/v_july_v/article/details/78121924 41. #include和#include“fi ...

  5. LINUX下C++编程如何获得某进程的ID

    #include <stdio.h> #include <stdlib.h> #include <unistd.h> using namespace std; pi ...

  6. chrome 浏览器 添加访问助手来访问网上应用商店

    chrome浏览器的强大之处,在于可以chrome浏览器的扩展程序来实现很多功能.然而不能下载扩展程序.可以借助chrome访问助手来实现: 下载chrome访问助手:https://pan.baid ...

  7. selenium(2):环境搭建完成后,初步运行遇到的问题

    检验是否搭建成功. . 问题一:运行时候,报错:请停用以开发者模式运行的扩展程序 出现错误如下: 原因:chromedriver的版本号过低了. 解决办法:应该安装与chrome版本对应的chrome ...

  8. GitHub的注册与使用

    1. 注册账号: 地址: https://github.com/输入账号.邮箱.密码,然后点击注册按钮. 2. 初始设置 注册完成后,选择Free免费账号完成设置 3.验证账号 新建一个仓库 发现邮箱 ...

  9. Linux下备份Mysql所有数据库

    需求:备份除了mysql系统数据库的所有数据库 以下为Shell脚本,只需要修改用户密码即可 MYSQL_USER=root MYSQL_PASS=123456 MYSQL_CONN="-u ...

  10. python学习笔记10--协程、IO、IO多路复用

    本节内容 一.协程 1.1.协程概念 1.2.greenlet 1.3.Gevent 1.4.协程之爬虫 1.5.协程之socket 二.论事件驱动与异步IO 三.IO 3.1.概念说明 3.2.IO ...