bind支持ipv6

环境

Centos5.8
bind-9.3.6-25.P1.el5_11.12

过程说明
  1. 服务器开启ipv6服务
    1. 网卡配置ipv6地址(当前机器都有配置)
    2. 网卡开启ipv6服务
    [root@localhost ~]# cat /etc/sysconfig/network
    NETWORKING=yes
    NETWORKING_IPV6=yes
    HOSTNAME=localhost.localdomain 
    
    如果NETWORKING_IPV6=no,需要修改为yes,然后重启服务器
  2. bind开启ipv6服务
    vi /etc/named.conf
    options {
        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内容如下:

$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服务

[root@localhost ~]# service named restart 
Stopping named:                                            [  OK  ]
Starting named:                                            [  OK  ]

5.查看dns解析结果

[root@localhost ~]# dig aaa.aa.com AAAA @127.0.0.1 +short
::1

注意点

  1. zone文件配置ipv6,是'IN AAAA';配置ipv4,是'IN A'。
  2. 在配置有ipv6的情况下,使用AAAA的选项查询主机的ipv6 AAAA记录,即dig命令添加AAAA选项。

验证结果
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服务器和nginx
2.curl -v -x 127.1:8080 http://aaa.aa.com/index.html,响应内容为"::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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、BIND是什么 BIND是互联网应用最为广泛的DNS软件。 二、BIND的安装与使用 以下内容转自 http:...
    0_0啊阅读 8,398评论 0 0
  • 1. 概述 在网络环境中一般用户只需要在浏览器中输入url如www.sunny.com就可以到对应服务器获取相应的...
    ghbsunny阅读 8,203评论 0 7
  • DNS服务器的基础应用及主从同步域名系统(英文:Domain Name System,缩写:DNS)是因特网的一项...
    linuxlove阅读 3,405评论 0 0
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 7,943评论 0 0
  • 目录(持续更新) 基础-第0章-安装基础-第1章-基本操作基础-第2章-磁盘及文件系统管理基础-第3章-获得帮助基...
    sky92archangel阅读 4,284评论 0 1