# 確保網(wǎng)絡(luò)接口配置使用dhcp方式
[root@localhost] cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
BOOTPROTO=dhcp
IPV6INIT=no
NM_CONTROLLED=no
ONBOOT="yes"
TYPE="Ethernet"
# 重啟網(wǎng)絡(luò)服務(wù)
[root@localhost] service network restart
Shutting down interface eth0: [OK]
Shutting down loopback interface: [OK]
Bringing up loopback interface: [OK]
Bringing up interface eth0:
Determining IP information for eth1… done. [OK]
# 檢查IP地址
[root@os03] ifconfig
eth1Link encap:EthernetHWaddr 00:0C:29:15:63:D9
inet addr:192.168.1.202Bcast:192.168.1.255Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe15:63d9/64 Scope:Link
UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1
RX packets:251 errors:0 dropped:0 overruns:0 frame:0
TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:36077 (35.2 KiB)TX bytes:4598 (4.4 KiB)
……
# 檢查默認(rèn)路由
[root@os03] route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric RefUse Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 000 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 00 eth1
配置DNS服務(wù)
DNSmasq能夠緩存外部DNS記錄,同時提供本地DNS解析或者作為外部DNS的代理,即DNSmasq會首先查找/etc/hosts等本地解析文件,然后再查找/etc/resolv.conf等外部nameserver配置文件中定義的外部DNS。所以說dnsmasq是一個很不錯的DNS中繼。DNS配置同樣寫入dnsmasq.conf配置文件里。
# 本地解析文件
#no-hosts
#addn-hosts=/etc/banner_add_hosts
# Set this (and domain: see below) if you want to have a domain
# automatically added to simple names in a hosts-file.
# 例如,/etc/hosts中的os01將擴(kuò)展成os01.debugo.com
expand-hosts
local=/debugo.com/
# 強(qiáng)制使用完整的解析名
domain-needed
# 添加額外的上級DNS主機(jī)(nameserver)配置文件
#resolv-file=
# 不使用上級DNS主機(jī)配置文件(/etc/resolv.conf和resolv-file)
no-resolv
# 相應(yīng)的,可以為特定的域名指定解析它的nameserver。一般是其他的內(nèi)部DNS name server
# server=/myserver.com/192.168.0.1
# 設(shè)置DNS緩存大小(單位:DNS解析條數(shù))
cache-size=500
# 關(guān)于log的幾個選項
log-queries
#log-dhcp
log-facility=/var/log/dnsmasq.log
# 異步log,緩解阻塞,提高性能。
log-async=20
# 指定domain的IP地址
address=/doubleclick.net/127.0.0.1
address=/.phobos.apple.com/202.175.5.114
配置完成后重啟dnsmasq,然后在客戶端測試:
[root@os03] nslookup os01.debugo.com
Server:192.168.1.132
Address:192.168.1.132#53
Name:os01.debugo.com
Address: 192.168.1.132
[root@os03] nslookup os02.debugo.com
Server:192.168.1.132
Address:192.168.1.132#53
Name:os02.debugo.com
Address: 192.168.1.201
[root@os03] nslookup doubleclick.net
Server:192.168.1.132
Address:192.168.1.132#53
Name:doubleclick.net
Address: 127.0.0.1
#注意,由于address選項解析為127.0.0.1,而非server的192.168.1.132地址。
[root@os03] nslookup a1.phobos.apple.com
Server:192.168.1.132
Address:192.168.1.132#53
Name:a1.phobos.apple.com
Address: 202.175.5.114
好了,說到這里應(yīng)該都會使用DNSmasq這個小工具了,簡單快捷,下一期,我們再講講如何搭建智能dns。更多精彩》》
更多關(guān)于云服務(wù)器,域名注冊,虛擬主機(jī)的問題,請訪問三五互聯(lián)官網(wǎng):m.shinetop.cn