美文网首页
bind支持ipv6

bind支持ipv6

作者: Show嘿嘿 | 来源:发表于2019-07-21 21:06 被阅读0次
环境

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支持ipv6

      本文链接:https://www.haomeiwen.com/subject/vaivlctx.html