linux 防火墙开端口(转)

vi /etc/sysconfig/iptables

-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火墙) 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT(允许3306端口通过防火墙) 
特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面

添加好之后防火墙规则如下所示:

###################################### 
# Firewall configuration written by system-config-firewall 
# Manual customization of this file is not recommended. 
*filter 
:INPUT ACCEPT [0:0] 
:FORWARD ACCEPT [0:0] 
:OUTPUT ACCEPT [0:0] 
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT 
-A INPUT -p icmp -j ACCEPT 
-A INPUT -i lo -j ACCEPT 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT 
-A INPUT -j REJECT –reject-with icmp-host-prohibited 
-A FORWARD -j REJECT –reject-with icmp-host-prohibited 
COMMIT 
#####################################

/etc/init.d/iptables restart  
     #最后重启防火墙使配置生效

?

时间: 2024-08-01 15:33:49

linux 防火墙开端口(转)的相关文章

linux防火墙开放端口时报ptables-restore: line 13 failed [失败]

linux开放8080端口 在/etc/sysconfig/iptables中添加一行[-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT] 然后service iptables restart,报下面问题 解决方法: 问题原因:对linux防火墙相关配置不熟悉: 参考链接:http://www.mamicode.com/info-detail-1179017.html

linux 防火墙打开端口/屏蔽IP等

开启/禁用 sudo ufw allow|deny [service] 打开或关闭某个端口,例如: sudo ufw allow smtp 允许所有的外部IP访问本机的25/tcp (smtp)端口 sudo ufw allow 22/tcp 允许所有的外部IP访问本机的22/tcp (ssh)端口 这个很重要,ssh远程登录用于SecureCRT等软件建议开启.或者不要开防火墙. sudo ufw allow 53 允许外部访问53端口(tcp/udp) sudo ufw allow from

linux防火墙及端口开关设置

一.Linux下开启/关闭防火墙命令 1) 永久性生效,重启后不会复原 开启: chkconfig iptables on 关闭: chkconfig iptables off 2) 即时生效,重启后复原 开启: service iptables start 关闭: service iptables stop 需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作. 在当开启了防火墙时,做如下设置,开启相关端口, 修改/etc/sysconfig/iptables 文件,添加以

linux防火墙开放端口,针对固定ip开放端口

编辑/etc/sysconfig/iptables,添加 -A INPUT -m state --state NEW -m tcp -p tcp -s 127.0.0.1 --dport 6379 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp -s 126.212.173.185 --dport 6379 -j ACCEPT 以上加红地方就是只对本机和126.212.173.185开放6379端口,其他ip用telnet是无法连接的,

linux防火墙开启端口

1.使用命令查看端口开启情况(下图为安装时未选择开启防火墙) [[email protected] ~]# iptables -L -n Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source d

linux 防火墙添加端口

1.在防火墙上添加端口 iptables -I INPUT -p tcp --dport 80 -j ACCEPT  //80为web服务发布端口iptables -I INPUT -p tcp --dport 22 -j ACCEPT  //22为ssh服务端口 2.保存服务的配置service iptables save 3.重启防火墙服务service iptables restart 4.查看防火墙service iptables status

linux防火墙的端口操作

开启:iptables -I INPUT -p tcp --dport 8161 -j ACCEPT #开启8011端口 关闭: iptables -I INPUT -p tcp --dport 8070 -j DROP #关闭8011端口 service iptables status 查看防火墙状态service iptables start 开启防火墙service iptables stop 关闭防火墙service iptables restart 重启防火墙 原文地址:https:/

linux防火墙开放端口

首先进入到cd /etc/sysconfig/ 这个目录,然后查看这个文件:vim iptables: 然后将自己想要开放端口写上去.(下图标注) 最后重启下服务service iptables restart 就行了..

linux防火墙对端口设置与查看

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT #开启80端口  /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 o