实现DNS主从域,http虚拟主机跟用户

发布时间:2020-05-24 23:05:47 作者:N39_lxq
来源:网络 阅读:327

DNS

域名解析是把域名指向网站空间IP,让人们通过注册的域名可以方便地访问到网站的一种服务。IP地址是网络上标识站点的数字地址,为了方便记忆,采用域名来代替IP地址标识站点地址。域名解析就是域名到IP地址的转换过程。域名的解析工作由DNS服务器完成。

1、安装dns服务器
[root@localhost ~]# yum -y install bind*
2、修改配置文件
在/etc/named.conf中:

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

然后创建解析:
vim /etc/named.rfc1912.zones

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

在/var/named/data/中创建web1.com.zone文件如下

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

3.启动named服务:

systemctl start named

ps -ef | grep named
显示启动成功

4 测试

[root@localhost ~]# nslookup 
> web1.com
Server:         192.168.159.130
Address:        192.168.159.130#53

Name:   web1.com
Address: 192.168.159.130

5.dns从域设置

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

重启服务后:

[root@localhost ~]# nslookup 
> web1.com
Server:         192.168.159.131
Address:        192.168.159.131#53

Name:   web1.com
Address: 192.168.159.130

HTTP

1安装HTTP服务
yum -y install httpd
2.编辑配置文件创建两个虚拟主机
vim /etc/httpd/conf/httpd.conf

<VirtualHost 192.168.159.130:80>
       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

</VirtualHost>
<VirtualHost 192.168.159.129:80>
       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
</VirtualHost>

3.添加一个地址
ip addr add 192.168.159.129 dev ens33
4 编辑主页文件

[root@localhost conf]# cat /var/www/html/vhost1/index.html 
床前明月光
[root@localhost conf]# cat /var/www/html/host1/index.html 
日照香炉生紫烟

5 访问成功
实现DNS主从域,http虚拟主机跟用户

实现DNS主从域,http虚拟主机跟用户

6 配置访问控制
在相应的地方插入以下哦欸之

<Directory "/var/www/html/vhost1">
        options None
        AllowOverRide AuthConfig
        AuthType Basic
        AuthName "wellcome to login .."
        AuthBasicProvider file
        AuthUserFile /etc/httpd/conf/.htpwd
        Require user zhangsan lisi
    </Directory>
         <Directory "/var/www/html/host1">
        options None
        AllowOverRide AuthConfig
        AuthType Basic
        AuthName "wellcome to login .."
        AuthBasicProvider file
        AuthUserFile /etc/httpd/conf/.htpwd
        Require user zhangsan lisi
    </Directory>

创建用户密码

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

7访问控制

实现DNS主从域,http虚拟主机跟用户
实现DNS主从域,http虚拟主机跟用户

推荐阅读:
  1. 域用户如何导入导出
  2. DNS域传送漏洞

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

学习 %d

上一篇:AndroidStudio——导出apk

下一篇:QT绘图五:绘制美化版本扫描方向表盘

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》