環(huán)境
Centos5.8
bind-9.3.6-25.P1.el5_11.12
過程說明
- 服務(wù)器開啟ipv6服務(wù)
- 網(wǎng)卡配置ipv6地址(當(dāng)前機器都有配置)
- 網(wǎng)卡開啟ipv6服務(wù)
如果NETWORKING_IPV6=no,需要修改為yes惧财,然后重啟服務(wù)器[root@localhost ~]# cat /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=yes HOSTNAME=localhost.localdomain
- bind開啟ipv6服務(wù)
vi /etc/named.confoptions { listen-on port 53 { 127.0.0.1; }; listen-on-v6 port 53 { ::1; }; ##ipv6 directory "/var/named/"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; }; view localhost_resolver { match-clients { localhost; }; match-destinations { localhost; }; recursion yes; zone "aa.com" IN { type master; file "aa.com.zone"; allow-update { none; }; }; };
3.配置zone文件
vi /var/named/aa.com.zone內(nèi)容如下:
$TTL 5
@ IN SOA @ root (
1997022700 ; Serial
8 ; Refresh
16 ; Retry
24 ; Expire
36 ) ; Minimum
@ IN NS aaa.
aaa IN AAAA 0:0:0:0:0:0:0:1
4.啟動bind服務(wù)
[root@localhost ~]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
5.查看dns解析結(jié)果
[root@localhost ~]# dig aaa.aa.com AAAA @127.0.0.1 +short
::1
注意點
- zone文件配置ipv6邢隧,是'IN AAAA'改化;配置ipv4,是'IN A'会钝。
- 在配置有ipv6的情況下,使用AAAA的選項查詢主機的ipv6 AAAA記錄,即dig命令添加AAAA選項簇爆。
驗證結(jié)果
nginx配置:
http {
upstream myserver.com {
server aaa.aa.com:8001;
}
server {
listen [::]:8080;
server_name aaa.aa.com;
resolver 127.0.0.1;
location / {
proxy_pass http://myserver.com;
}
}
server {
listen [::]:8001;
server_name localhost;
location / {
return 200 '$server_addr';
}
}
}
步驟:
1.啟動上述配置的bind服務(wù)器和nginx
2.curl -v -x 127.1:8080 http://aaa.aa.com/index.html剔猿,響應(yīng)內(nèi)容為"::1"
[root@localhost ~]# curl -v -x 127.1:8080 http://aaa.aa.com/index.html
* About to connect() to proxy 127.1 port 8080
* Trying 127.0.0.1... connected
* Connected to 127.1 (127.0.0.1) port 8080
> GET http://aaa.aa.com/index.html HTTP/1.1
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: aaa.aa.com
> Pragma: no-cache
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Server: nginx/1.13.6
< Date: Thu, 12 Jul 2018 09:04:11 GMT
< Content-Type: text/html
< Content-Length: 3
< Connection: keep-alive
Connection #0 to host 127.1 left intact
* Closing connection #0
::1