Linux下設(shè)置Iptable只允許某個(gè)ip訪問3306端口

2014年12月31日19:04:15 發(fā)表評(píng)論 7,951 ℃

Linux防火墻Iptable如何設(shè)置只允許某個(gè)ip訪問3306端口,只允許特定ip訪問某端口?參考下面命令,只允許1.2.3.4訪問本機(jī)的3306端口。如果要設(shè)置其他ip或端口,改改即可。

-A INPUT -p TCP --dport 3306 -j DROP

-A INPUT -s 1.2.3.4 -p TCP --dport 3306 -j ACCEPT

在root用戶下vi /etc/sysconfig/iptables添加上面命令,重啟iptables, service iptables restart

查看iptables是否生效:

[root@www.msadmin.cn]# iptables -L

Chain INPUT (policy ACCEPT)

target prot opt source destination

ACCEPT tcp -- 1.2.3.4 anywhere tcp dpt:http

DROP tcp -- anywhere anywhere tcp dpt:http

Chain FORWARD (policy ACCEPT)

target prot opt source destination

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

【騰訊云】云服務(wù)器、云數(shù)據(jù)庫(kù)、COS、CDN、短信等云產(chǎn)品特惠熱賣中

發(fā)表評(píng)論

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: