How to Build a Linux DNS, NFS, and Local Yum Repo with Nginx
This guide walks you through installing and configuring a Bind DNS server, setting up NFS sharing on Linux, and creating a local YUM repository served by Nginx, complete with command‑line steps, configuration file edits, and troubleshooting tips.
Linux DNS Server Setup
Install the required packages:
yum -y install bind yum install bind-utils -yEdit the main configuration file: vi /etc/named.conf Check the configuration syntax: named-checkconf Modify the zone definition file:
vi /etc/named.rfc1912.zonesPrepare forward zone data:
Copy the template file and keep permissions:
Edit the zone file:
Prepare reverse zone data:
Copy the forward zone file as a reverse template:
Edit the reverse zone file:
Restart the DNS service and test: systemctl restart named Edit /etc/resolv.conf to point to the new nameserver (e.g., nameserver 192.168.127.11).
Forward lookup test:
Reverse lookup test:
Linux NFS Server Configuration
Server side
Install required packages:
Enable services at boot and start them:
Create and export a shared directory (example: /home/nfs with full permissions):
Refresh export table:
Open firewall port 2049 for NFS:
Restart services to apply changes:
Verify exported directories:
Client side
Install the same packages and start services:
Check available exports from the server:
Create a mount point and mount the NFS share:
Persist the mount via /etc/fstab:
Common NFS startup issue
If rpcbind fails with “Failed to listen on RPCbind Server Activation Socket”, disable IPv6 and adjust the socket file:
vim /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
sysctl -p
find /etc -name 'rpcbind.socket'
vim /etc/systemd/system/sockets.target.wants/rpcbind.socket
systemctl daemon-reload
systemctl restart rpcbind
systemctl restart nfsCreating a Local Yum Repository with Nginx
1. Install Nginx and its build dependencies
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-develDownload, extract, compile, and install Nginx (example version 1.19.4):
tar -zxvf nginx-1.19.4.tar.gz
cd nginx-1.19.4
./configure && make && make installVerify the configuration and add Nginx to the system path:
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -V
cp /usr/local/nginx/sbin/nginx /usr/local/sbin/Enable automatic start: echo "/usr/local/sbin/nginx" >> /etc/rc.local Control commands:
Start: nginx Stop: kill $(cat /var/run/nginx.pid) Reload: nginx -s reload 2. Prepare the local Yum repository files
Create a directory for the repository, e.g., /data/centos/6 and /data/centos/7, and copy the ISO contents into it.
Copy repodata/repomd.xml to the parent directory.
3. Configure Nginx to serve the repository
Example nginx.conf snippet (place inside the http block):
server {
listen 80;
server_name yum.local;
root /data/centos;
autoindex on;
}Reload Nginx after editing: nginx -s reload 4. Configure client machines to use the new repo
Create /etc/yum.repos.d/Local.repo with content similar to:
Refresh the cache and verify:
This complete workflow enables a self‑contained DNS service, NFS sharing, and a private YUM repository, useful for isolated networks or lab environments.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
