iofdata / DM

Data Mining Books and Tools.
0 stars 1 forks source link

Linux 网络防火墙和端口设置 #9

Open Buttonwood opened 10 years ago

Buttonwood commented 10 years ago

Linux 防火墙

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT #开启80端口 
/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT #开启22端口 
/etc/rc.d/init.d/iptables save #保存配置 
/etc/rc.d/init.d/iptables restart #重启服务 
/etc/init.d/iptables status #查看已开放端口 

结果如下 
Table: filter 
Chain INPUT (policy ACCEPT) 
num target prot opt source destination 
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 
3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 

linux开启防火墙端口和查看,开启相关端口号

# 即时生效,重启后失效
service iptables start 
service iptables stop

# 重启后生效
chkconfig iptables on
chkconfig iptables off

echo "-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT" >> /etc/sysconfig/iptables

lsof -i:23