linux iptables dns端口,iptables 打开dns访问端口

今天在测试本机DNS的时候发现无法解释域名,经查原因出在iptables上边。

我立即加了 iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT 的链路,发现还是

不行。一般认为DNS就是通过访问DNS服务器的53端口进行域名解释的。本机端口应该是任意的,

可是就是不通。

没有办法再添加iptables -t filter -j LOG -p udp --log-prefix "DNS monitor: " 添加一

个日志功能。

添加了以上记录后,还不能记录那个功能。还需要再在

/etc/syslog.conf

添加一个记录,

kern.warning /var/log/iptables.log

kern是设备名,warning 是记录级别,/var/log/iptables.log 记录日志文件位置。

其中的具体设置如果大家有兴趣可以另外查找一下其它的文档。

最后重启一下syslog服务。

service syslog restart

现在就可以了。

使用nslookup

然后我们看一下/var/log/iptables.log文件

:10:db:69:43:50:08:00 SRC=219.141.140.10 DST=192.2.8.185 LEN=169 TOS=0x00 PREC=0x00

TTL=241 ID=63822 DF PROTO=UDP SPT=53 DPT=45623 LEN=149

里面的SPT=53是53,也就是我们需要开放53端口。

iptables -t filter -A INPUT -p udp -m udp -j ACCEPT

nslookup

Server:         219.141.140.10

Address:        219.141.140.10#53

现在再执行nslookup

Non-authoritative answer:

canonical name = jupiter.sina.com.cn.

jupiter.sina.com.cn     canonical name = hydra.sina.com.cn.

Name:   hydra.sina.com.cn

Address: 218.30.108.189

Name:   hydra.sina.com.cn

Address: 218.30.108.190

Name:   hydra.sina.com.cn

Address: 218.30.108.191

可以了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值