题意:
在Linux主机上实现www.abc.com域名的访问,且也能实现IP地址直接访问,IP为:192.168.0.15.
在接下来的web服务的配置中需要设置虚拟主机,用来访问网址:ftp.abc.com,且也能实现IP地址直接访问,IP为:192.168.0.15.
分析:
1.Linux的主机名称设置为:www
2.Linux主机架设主(根)DNS服务器
3.修改httpd.conf配置:servername www.abc.com:80
一、更改主机名称
linux更改主机名,需要更改两个文件如下:
vi /etc/hosts
vi /etc/sysconfig/network
将主机名称更改为:www
更改后文件内容如下:
/etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.0.15 www www
二、更改/etc/name.conf配置文件
在下列内容
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};
添加如下内容:
将:
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
更改为:
zone "abc.com" IN{
type master;
file "named.abc.com";
allow-update{ none; };
};
将:
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
更改为:
zone "0.168.192.in-addr.arpa" IN {
type master;
file "named.0.168.192";
allow-update { none; };
};
当然最好是在原有文件的基础上进行更改.
三、创建正向解析文件named.abc.com
-->此文件已经在/etc/name.conf中指定!!
[root@localhost named]# cp localdomain.zone named.abc.com
其位置位于:/var/named/chroot/var/named/
内容如下:(注意:可以参考此目录下的localdomain.zone文件)
$TTL 86400
@ IN SOA www.abc.com. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS www.abc.com.
www IN A 192.168.0.15
ftp IN A 192.168.0.15
四、创建反向解析文件named.0.168.192
-->此文件同样已经在/etc/name.conf中指定!!
[root@localhost named]# cp named.local named.0.168.192
其位置位于:/var/named/chroot/var/named/
内容如下:(注意:可以参考此目录下的named.local文件)
$TTL 86400
@ IN SOA www.abc.com. root (
|