Posts

How to Install and Configure dnsmasq in Linux

Introduction

Dnsmasq is a lightweight DNS forwarder and resource constrained routers and firewalls. It is widely used for tethering on smartphones and portable hotspots, and to support virtual networking in virtualisation frameworks. Dnsmasq is included in most Linux distributions like FreeBSD, OpenBSD and NetBSD.

Step 1: Install dnsmasq

First install dnsmasq package using yum command.

# yum -y install dnsmasq

Step 2: Configuration

Configure dnsmasq service as per following settings.

# vi /etc/dnsmasq.conf
# line 19: uncomment (never forward plain names)
domain-needed
# line 21: uncomment (never forward addresses in the non-routed address spaces)
bogus-priv
# line 41: uncomment (query with each server strictly in the order in resolv.conf)
strict-order
# line 55: add if you need
# query the specific domain name to the specific DNS server
# the example follows means query [server.education] domain to the [10.0.0.10] server
server=/server.education/10.0.0.10
# line 123: uncomment (add domain name automatically)
expand-hosts
# line 133: add (define domain name)
domain=tecdistro

Step 3: Start Service

Run the DHCP service by using below command and start service.

# systemctl start dnsmasq
# systemctl enable dnsmasq

Step 4: Entry in hosts file

# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# add records
10.0.0.30   dlp.tecdistro dlp 

Restart the dnsmasq service.

# systemctl restart dnsmasq

Step 5: Add service in firewall

# firewall-cmd --add-service=dns --permanent 
success
# firewall-cmd --reload 
success

How to Change the IP address in LINUX

Method 1: Command Line

Step 1: Edit in /etc/sysconfig/network File

In order to change the IP address edit the following files:

# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=tecdistro.com

Step 2: Modify in Interface

To change the interface edit the following file:
# vim /etc/network/interfaces
Also change the network script file:

# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=06:b8:60:e2:ad:3f
IPADDR=10.104.254.244
NETMASK=255.255.255.192

Step 3: Restart Network

Now restart the network:

/etc/init.d/network restart

Method 2: GUI Environment

Step 1: Execute setup Command

# setup

Select Network Configuration Tab
setup1

Step 2: Select Device Configuration

setup2

Step 3: Select ethernet

setup3

Step 4: Modify Network Configurations

setup4
Once the changes have made, Select SAVE & QUIT and press ENTER key from keyboard.