Chris Paquin

AI, Virtualization, Containers, Infrastructure, Linux

Tag: redhat. linux

  • How to Install and Configure Dnsmasq with Web Frontend on RHEL 9

    How to Install and Configure Dnsmasq with Web Frontend on RHEL 9

    In this post we are going to install and configure dnsmasq with a simple webUI acting as a front end for our less technical users. Our goal is to simplify dns in our lab sandboxes, and keep users from directly modifying our dnsmasq config files.

    Installation

    First we need to install dnsmasq.

    # dnf -y install dnsmasq

    Now lets enable and start the service. We will also check the status of the service to ensure that we do not have any issues with the default config.

    # systemctl start dnsmasq
    # systemctl enable dnsmasq
    # systemctl status dnsmasq

    Configuration

    Next let’s make a backup of the default configuration file before we start making modification.

    cp /etc/dnsmasq.conf /etc/dnsmasq.conf.orig

    I made the following modifications.

    1. listen-address is the loopback and our routable ip address
    2. expand-hosts, we uncomment this in order to allow dnsmasq to automatically expand the hostnames to fully qualified domain names
    3. domain – this is the local domain that we will serve via dnsmasq
    4. dhcp-range – this is the range of IP addresses that dnsmasq is allowed to hand out
    interface=enp1s0
    listen-address=127.0.0.1,192.168.65.7
    expand-hosts
    domain=sandbox3.localdomain
    dhcp-range=192.168.65.20,192.168.65.40,255.255.255.128,12h
    

    Next we check our config file for any errors

    # dnsmasq --test
    dnsmasq: syntax check OK.

    Now lets restart dnsmasq

    # systemctl restart dnsmasq

    Firewall Config

    Now we need to modify firewalld

    [root@dns ~]#  firewall-cmd --add-service=dns --permanent
    success
    [root@dns ~]# firewall-cmd --add-service=dhcp --permanent
    success
    [root@dns ~]# firewall-cmd --reload
    success

    Testing

    I prefer to use nslookup for testing, so lets install it

    # dnf -y install bind-utils

    Now let’s make sure we are able to resolve addresses, using our local instance of dnsmasq.

    # nslookup
    > server localhost
    Default server: localhost
    Address: ::1#53
    Default server: localhost
    Address: 127.0.0.1#53
    > google.com
    Server:		localhost
    Address:	::1#53
    
    Non-authoritative answer:
    Name:	google.com
    Address: 142.251.40.174
    Name:	google.com
    Address: 2607:f8b0:4006:821::200e
    

    Install and Configure the Webui

    For the webui – we are going to use a simple one that I found via the link below. https://github.com/akivajp/dnsmasq-webconf

    First, we need to install git and pip

    # dnf -y install git
    # dnf -y install pip

    Then we follow the directions which I will repeat here.

    # mkdir -p ~/git && cd ~/git
    # git clone https://github.com/akivajp/dnsmasq-webconf.git

    Then we use pip to install jinja2

    # pip install --user bottle jinja2

    Now change directory

    # cd dnsmasq-webconf/

    We now need to poke a hole for http traffic in our local firewall

    # firewall-cmd --add-service=http --permanent
    # firewall-cmd --reload

    Now start the front end

    #  python ~/git/dnsmasq-webconf/app/index.py 80 --leases /var/lib/dnsmasq/dnsmasq.leases --hosts /etc/hosts --config /etc/dnsmasq.conf

    Creating a Service

    So far we have dnsmasq configured and running, and we have installed a web front end and have been able to start it on the command line. Now we need to configure the front end to start as a service when the OS boots. So we now need to turn the webUI into a systemd service.

    First we create the following service file

    # vi /etc/systemd/system/dnsmasq-webconf.service

    The contents of which are below. Note that we have modified relative paths to be absolute paths.

    [Unit]
    Description=DNSMasq WebConf
    After=network.target
    
    [Service]
    ExecStart=/usr/bin/python3 /root/git/dnsmasq-webconf/app/index.py 80 --leases /var/lib/dnsmasq/dnsmasq.leases --hosts /etc/hosts --config /etc/dnsmasq.conf
    Restart=always
    User=root
    WorkingDirectory=/root/git/dnsmasq-webconf/app
    StandardOutput=journal
    StandardError=journal
    
    [Install]
    WantedBy=multi-user.target

    Now we need to reload systemd

    # systemctl daemon-reload

    Now we can start the service

    # systemctl start dnsmasq-webconf.service

  • OpenSCAP Part 3: Running Scans from the Command Line in RHEL 7

    openscap-base

    Introduction

    In part 1 of this series we were introduced to OpenSCAP and the process of running scans via the SCAP workbench. In part 2, we explored concepts and components that define security/vulnerability scans. In this 3rd post we are going to dive into the command line operation.

    Let’s get started with oscap.

    Installing oscap

    In RHEL 7 oscap can be installed with the following command

    # yum -y install scap-security-guide openscap-scanner

    Content is installed under the following directory. Note that ssg is short for SCAP Security Guide.

    /usr/share/xml/scap/ssg/content

    Lets change directories to the one listed above and view the installed files.

    Screenshot from 2019-07-24 15-58-04

    Using oscap we can view more info on each file shown above. In this example we are going to inspect the ssg-rhel7-ds.xml file.

    # oscap info ssg-rhel7-ds.xml

    (more…)

  • RHEL6 – Common Postfix Server Roles

    10736157-a-cartoon-rabbit-with-an-angry-expressionIf you are anything like me you would rather not have anything to do with Sendmail or Postfix, however unfortunately it can be required learning in some circles. That being said this is my second postfix post in what I call my “Postfix: Nasty!” series. The first one can be read here, and  I will be the first to admit that its not very good. However I chock this up to the fact that I really don’t know much about Postfix at all and I’m writing these posts as part of the process of figuring out how to do what with Postfix.

    Specifically this post outlines and defines the standard roles that a postfix server can serve. Below are three common roles and their characteristics. You should get to know each of these and how to configure them.

    Null Client:

    • Only runs Postfix as a local MTA (mail transfer agent… think sendmail and postfix) for the purpose of forwarding to a centralized mail server
    • Does not accept local delivery

    Inbound-Only Mail Server:

    • Handles all inbound mail for a site
    • Passes inbound email to an MDA (mail delivery agent) such as Dovecot or Procmail
    • Forwards outbound mail to a centralized mail server, just like a Null Client Does

    Outbound Mail Relay:

    • Also called a Smarthost
    • Accepts outbound messages
    • Should be configured to forward mail for authorized clients only. Avoid being an Open Relay