iptables 設(shè)置特定IP訪問指定端口
查詢、刪除規(guī)則指令
測試telnet
telnet 127.0.0.1 8075
1、查詢規(guī)則編號(hào):
[root@zabbix_server ~]# iptables --line -nvL INPUT
Chain INPUT (policy DROP 83 packets, 4016 bytes)
num pkts bytes target prot opt in out source destination
1 8 408 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8075
2 144M 15G ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
可以看到禁止訪問8075的規(guī)則編號(hào)為1
2、刪除指定規(guī)則編號(hào)的規(guī)則(如刪除編號(hào)為1的規(guī)則)
iptables -D INPUT 1
實(shí)踐
1、添加規(guī)則:禁止所有IP訪問8075
iptables -I INPUT -p tcp --dport 8075 -j DROP
2、添加規(guī)則:允許127.0.0.1訪問8075
[root@zabbix_server ~]# iptables -I INPUT -s 127.0.0.1 -p tcp --dport 8075 -j ACCEPT
[root@zabbix_server ~]# iptables -I INPUT -s 172.16.200.10 -p tcp --dport 8075 -j ACCEPT
3、測試:文章來源:http://www.zghlxwxcb.cn/news/detail-729743.html
telnet 127.0.0.1 8075
4、保存規(guī)則文章來源地址http://www.zghlxwxcb.cn/news/detail-729743.html
[root@zabbix_server ~]# service iptables save
到了這里,關(guān)于linux中iptables 設(shè)置特定IP訪問指定端口的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!