in Server

CentOS: Cài đặt & cấu hình Dnsmasq Server phục vụ local network

Yêu cầu:

Server đồng thời vừa có kết nối Internet và LAN

Cài đặt & cấu hình Dnsmasq chỉ phục vụ trên mạng LAN, không phân giải các domain ngoài internet

Thông tin mạng:

Interface Internet (eth0): 192.168.11.253
Interface LAN (eth1):        10.1.1.1
Phân giải LAN:                   mydomain.local => 10.1.1.1

 

 

Cấu hình eth0 (Internet):

$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
NAME="Internet"
DEVICE=eth0
HWADDR=xx:xx:xx:xx:xx:xx
TYPE=Ethernet
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.11.253
NETMASK=255.255.255.0
GATEWAY=192.168.11.1
DNS1= 8.8.8.8
DNS2= 203.113.188.1
DNS3= 203.119.36.106
PEERDNS=no
IPV6INIT=no
IPV6_AUTOCONF=no

 

Cấu hình eth1 (LAN):

$ vi /etc/sysconfig/network-scripts/ifcfg-eth1
NAME="LAN"
DEVICE=eth1
HWADDR=xx:xx:xx:xx:xx:xx
TYPE=Ethernet
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=10.1.1.1
IPV6INIT=no
IPV6_AUTOCONF=no

 

Cài Dnsmasq:

$ yum -y install dnsmasq

 

Cấu hình Dnsmasq:

$ vi /etc/dnsmasq.conf
domain-needed
bogus-priv

domain=mydomain.local
expand-hosts
local=/mydomain.local/

listen-address=10.1.1.1
interface=eth1
no-dhcp-interface=eth1
no-resolv
#bind-interfaces

 

Cấu hình IP của DNS server:

$ vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 203.113.188.1
nameserver 203.119.36.106

 

Cập nhật file hosts:

$ vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
10.1.1.1 mydomain.local
192.168.1.253 myserver2.vhp.local myserver2
::1 localhost6.localdomain6 localhost6

 

Cuối cùng là khởi động lại các services:

$ chkconfig dnsmasq on
$ service dnsmasq restart
$ service network restart

Write a Comment

Comment