Get the App
SLTechnology News&Howtos  ›  Servers  › 

Realize DNS master-slave domain, http virtual host and user

Shulou Source: shulou.com Published: 2022-06-03 05:52:43 11月14日 Update

DNS domain name resolution is a service that points domain names to website space IP so that people can easily access websites through registered domain names. IP address is a digital address that identifies a site on the network. For convenience of memory, domain names are used instead of IP addresses to identify site addresses. Domain name resolution is the process of converting domain names into IP addresses. Domain name resolution is done by DNS servers.

1. Install DNS Server

[root@localhost ~]# yum -y install bind*

2. Modify the configuration file

In/etc/named.conf:

listen-on port 53 { any; }; allow-query { any; };

Then create a resolution:

vim /etc/named.rfc1912.zones

zone "web1.com" IN { type master; file "data/web1.com.zone"; };

Create web1.com.zone file in/var/named/data/as follows

$TTL 3H@ IN SOA web1.com. root ( 20180928 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS @ IN A 192.168.159.130www IN A 192.168.159.130

3. Start the named service:

systemctl start namedps -ef |grep named shows successful startup

4 test

[root@localhost ~]# nslookup > web1.comServer: 192.168.159.130Address: 192.168.159.130#53Name: web1.comAddress: 192.168.159.130

5. dns slave domain settings

vim /etc/named.rfc1912.zoneszone "web1.com" IN { type slave; file "slaves/web1.com.zone"; masters { 192.168.159.130;};};

After restarting the service:

[root@localhost ~]# nslookup > web1.comServer: 192.168.159.131Address: 192.168.159.131#53Name: web1.comAddress: 192.168.159.130HTTP

1 Installing HTTP Services

yum -y install httpd

2. Edit profile to create two virtual hosts

vim /etc/httpd/conf/httpd.conf

ServerAdmin webmaster@dummy-host.example.com DocumentRoot /var/www/html/host1/ ServerName 192.168.159.130 ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common ServerAdmin webmaster@dummy-host.example.com ServerAdmin webmaster@dummy-host.example.com DocumentRoot /var/www/html/host1/ ServerName 192.168.159.130 ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common

3. Add an address

ip addr add 192.168.159.129 dev ens33

4 Edit Home File

[root@localhost conf]#cat/var/www/html/vhost1/index.html [root@localhost conf]#cat/var/www/html/host1/index.html

5 successful visits

6 Configuring access control

Insert the following in the corresponding place

options None AllowOverRide AuthConfig AuthType Basic AuthName "wellcome to login .. " AuthBasicProvider file AuthUserFile /etc/httpd/conf/.htpwd Require user zhangsan lisi options None AllowOverRide AuthConfig AuthType Basic AuthName "wellcome to login .. " AuthBasicProvider file AuthUserFile /etc/httpd/conf/.htpwd Require user zhangsan lisi

Create a user password

htpasswd -c -m /etc/httpd/conf/.htpwd zhangsan htpasswd -m /etc/httpd/conf/.htpwd lisi htpasswd -m /etc/httpd/conf/.htpwd wangwu

7 Access control

Tags: Domain name address service file configuration success server site website control host user virtual host superscript two home page people place password that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Apple Shulou Information MySQL macOS