前几天,趁着研究bind9的DoS vul,又重温了一下bind相关的一些安全设置。 以前常见的一个比较容易忽略的问题是忘记设置allow-transfer,这样会导致比较严重的信息泄露。以下是我参考http:///samplechap/dnsbind4/dns&bind4-11.pdf后,总结的一些需要注意的地方。
1.隐藏bind的版本 options { version "None of your business"; }; 验证方法: dig @ip.addr txt chaos bind.version 2.限制查询 限制所有查询的方法: options { allow-query { address_match_list; }; }; 限制关于某个特定区的查询 acl "HP-NET" { 15/8; }; zone "hp.com" { type slave; file "bak.hp.com"; masters { 15.255.152.2; }; allow-query { "HP-NET"; }; };
如果有多ip的话,可以限制某个查询所使用的ip地址 listen-on { 192.249.249.3; };
3.防止未授权的区传递 zone "movie.edu" { type master; file "db.movie.edu"; allow-transfer { 192.249.249.1; 192.253.253.1; 192.249.249.9; 192.253.253.9; }; }; 只允许那些辅名字服务器从主名字服务器传输movie.edu 区的数据。 因为BIND 8 和9 的默认配置是允许所有IP 地址进行区传送,而且因为黑客可以很容易地从辅名字服务器那里获得区的数据,你也许应该在辅名字服务器上也加上以下的zone 语句: zone "movie.edu" { type slave; masters { 192.249.249.3; }; file "bak.movie.edu"; allow-transfer { none; }; };
也可以在全局options中,设置只有内部的ip地址才能进行区传送: options { allow-transfer { 192.249.249/24; 192.253.253/24; 192.253.254/24; }; };
测试方法: 使用dnswalk
4.使用chroot的方式运行bind9 bind9采取源码make install方式安装的话,就可以看出他本身就是为chroot running准备的。具体的,可以看一下man,或者google。
5.针对授权dns的一些安全配置 关闭递归查询功能(递归查询应该是企业内部的dns服务器所提供的功能) options { recursion no; }; 在bind8中,还需关闭fetch-glue, bind9之后已经默认关闭了。 options { fetch-glue no; };
6.利用视图(view)将授权和查询两个功能和二为一 options { directory "/var/named"; }; acl "internal" { 192.249.249/24; 192.253.253/24; 192.253.254/24; }; view "internal" { match-clients { "internal"; }; recursion yes; zone "movie.edu" { type master; file "db.movie.edu"; }; zone "249.249.192.in-addr.arpa" { type master; file "db.192.249.249"; }; zone "." { type hint; file "db.cache"; }; }; view "external" { match-clients { any; }; recursion no; zone "movie.edu" { type master; file "db.movie.edu"; }; zone "249.249.192.in-addr.arpa" { type master; file "db.192.249.249"; }; zone "." { type hint; file "db.cache"; }; };
另外,尽管dnssec已经喊了很多年,同时有了去年dns cache poison的教训。但是我觉得,在可见的一段时间内,还是比较难以部署的。
|