使用iptable实现: 放行ssh,telnet, ftp, web服务80端口,其他端口服务全部拒绝
端口检查
需要放行端口 ssh:22 telnet:20,21 ftp:23 web:80,443 samba tcp:139,445 samba udp:137,138
操作过程
# 允许本机10.0.0.11访问ssh端口 [root@node1 ~]# iptables -I INPUT -s 10.0.0.11 -p tcp --dport 22 -j ACCEPT # 允许已建立的链接通过(小心操作) [root@node1 ~]# iptables -I INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT #放行端口 [root@node1 ~]# iptables -A INPUT -p tcp -m multiport --dports 20,21,23,80,443,139,445 -j ACCEPT [root@node1 ~]# iptables -A INPUT -p udp --dport 137:138 -j ACCEPT #拒绝其他所有连接(小心操作) [root@node1 ~]# iptables -A INPUT -j REJECT # 查看防火墙规则 [root@node1 ~]# iptables -nvL Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 37 2268 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 0 0 ACCEPT tcp -- * * 10.0.0.11 0.0.0.0/0 tcp dpt:22 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 20,21,23,80,443,139,445 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpts:137:138 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination
标签:ftp,web,--,0.0,端口,tcp,ACCEPT,80 From: https://www.cnblogs.com/feifa/p/16054331.html