Linux Server Network Services Setup
DNS and DHCP Installation Exercise
This document outlines the steps to install and configure essential network services on a Linux server, including DNS (BIND), DHCP, HTTPD (Apache), and VSFTPD.
DNS Server Configuration (BIND)
1. Install BIND Packages
Begin by installing the necessary BIND packages using yum
:
[root@localhost ~]# yum -y install bind bind-chroot bind-libs caching-nameserver
2. Configure BIND Named.conf
Edit the main BIND configuration file to define your DNS zones:
[root@localhost ~]# vi /var/named/chroot/etc/named.conf
Add the following zone definitions for your domain (sergio.cl
) and its reverse lookup zone:
Zone "sergio.cl" IN {
type master;
file "var/named/directa";
allow-update {192.168.0.0/24;};
};
Zone "0.168.192.in-addr.arpa" IN {
type master;
file "var/named/inversa";
allow-update {192.168.0.0/24;};
};
3. Prepare Zone Files and Permissions
Copy the default local zone file to create your forward (directa
) and reverse (inversa
) zone files, and adjust permissions:
[root@localhost ~]# ll
[root@localhost ~]# chown root.named named.conf
[root@localhost ~]# ll
[root@localhost ~]# cp /var/named/chroot/var/named/named.local directa
[root@localhost ~]# cp /var/named/chroot/var/named/named.local inversa
4. Configure Forward Zone File (sergio.cl)
Edit the forward lookup zone file (directa
) to map hostnames to IP addresses:
[root@localhost ~]# vi directa
Add the following content, ensuring correct record types:
$TTL 86400
@ IN SOA ns1.sergio.cl. root.sergio.cl. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns1.sergio.cl.
ns1 IN A 192.168.0.2
eyeos IN A 192.168.0.2
5. Configure Reverse Zone File (0.168.192.in-addr.arpa)
Edit the reverse lookup zone file (inversa
) to map IP addresses to hostnames:
[root@localhost ~]# vi inversa
Add the following content, ensuring correct FQDN formatting:
$TTL 86400
@ IN SOA ns1.sergio.cl. root.sergio.cl. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns1.sergio.cl.
2 IN PTR ns1.sergio.cl.
6. Set Zone File Permissions and Resolver
Adjust permissions for the new zone files and configure the system’s resolver to use your new DNS server:
[root@localhost ~]# ll
[root@localhost ~]# chown root.named directa
[root@localhost ~]# chown root.named inversa
[root@localhost ~]# vi /etc/resolv.conf
Add or modify the following lines in /etc/resolv.conf
:
search sergio.cl
nameserver 192.168.0.2
7. Activate Network Interface and Start BIND
Set the IP address for your network interface and start the BIND service:
[root@localhost ~]# /sbin/ifconfig eth0 192.168.0.2
[root@localhost ~]# /etc/init.d/named start
Expected output for starting BIND:
Iniciando named: [ OK ]
8. Verify DNS Resolution with nslookup
Test your DNS configuration using nslookup
:
[root@localhost ~]# nslookup
[root@localhost ~]# nslookup 192.168.0.2
Restart the network service to ensure all changes are applied:
[root@localhost ~]# service network restart
DHCP Server Configuration
1. Install DHCP Server
Install the DHCP server package:
[root@localhost ~]# yum -y install dhcp
2. Prepare DHCP Configuration File
Copy the sample configuration file and then edit it:
[root@localhost ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
[root@localhost ~]# vi /etc/dhcpd.conf
3. Configure Network Interface and Restart DHCP
Ensure your network interface has the correct IP and restart the DHCP service:
[root@localhost ~]# /sbin/ifconfig eth0 192.168.0.2
[root@localhost ~]# service dhcpd restart
[root@localhost ~]# service network restart
4. Edit DHCPD.conf for Subnet and Options
Open /etc/dhcpd.conf
again to define your subnet, IP range, and other DHCP options:
[root@localhost ~]# vi /etc/dhcpd.conf
Add or modify the following configuration block:
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0
{
# --- default gateway
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option nis-domain "sergio.cl";
option domain-name "sergio.cl";
option domain-name-servers 192.168.0.2;
option time-offset -18000; # Eastern Standard Time
#option ntp-servers 192.168.0.1;
# option netbios-name-servers 192.168.0.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.0.128 192.168.0.254;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
# host ns {
# next-server marvin.redhat.com;
# hardware ethernet 12:34:56:78:AB:CD;
# fixed-address 207.175.42.254;
}
5. Final DHCP Service Restart
Restart the DHCP service to apply the new configuration:
[root@localhost ~]# service dhcpd restart
Expected output:
Iniciando dhcpd: OK ]
Web Server Configuration (Apache HTTPD)
1. Install Apache HTTPD
Install the Apache HTTPD web server package:
[root@localhost ~]# yum -y install httpd
2. Start and Enable HTTPD Service
Start the HTTPD service and configure it to start automatically on boot:
[root@localhost ~]# service httpd restart
Expected output:
Parando httpd:[ OK ]
Iniciando httpd: [ OK ]
[root@localhost ~]# chkconfig --level 35 httpd on
3. Configure HTTPD and Create Index Page
You can modify the main HTTPD configuration file if needed, and then create a simple index.html
file for your website:
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
[root@localhost ~]# vi /var/www/html/index.html
(Write content to the index.html
file. Afterwards, open a web browser and navigate to http://localhost
to view your page.)
FTP Server Configuration (VSFTPD)
1. Install VSFTPD
Install the VSFTPD (Very Secure FTP Daemon) package:
[root@localhost ~]# yum -y install vsftpd
2. Start VSFTPD Service
Start the VSFTPD service:
[root@localhost ~]# service vsftpd start
Expected output:
Iniciando vsftpd para vsftpd:[ OK ]
3. Configure VSFTPD and Create Test File
Edit the VSFTPD configuration file as required, and create a test file in the FTP public directory:
[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf
[root@localhost ~]# touch /var/ftp/pub/holaaaaaaa
4. Verify FTP Access
(Open a web browser and navigate to ftp://localhost to verify FTP access.)