linux防火墙及端口开关设置

一.Linux下开启/关闭防火墙命令

1) 永久性生效,重启后不会复原

开启: chkconfig iptables on

关闭: chkconfig iptables off

2) 即时生效,重启后复原

开启: service iptables start

关闭: service iptables stop

需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。

在当开启了防火墙时,做如下设置,开启相关端口,

修改/etc/sysconfig/iptables 文件,添加以下内容:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

二.UBuntu关闭防火墙

iptables -A INPUT -i !   PPP0   -j ACCEPT

三.CentOS Linux 防火墙配置及关闭

执行”setup”命令启动文字模式配置实用程序,在”选择一种工具”中选择”防火墙配置”,然后选择”运行工具”按钮,出现防火墙配置界面,将”安全级别”设为”禁用”,然后选择”确定”即可.

或者用命令:

#/sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT

#/sbin/iptables -I INPUT -p tcp –dport 22 -j ACCEPT

#/etc/rc.d/init.d/iptables save

这样重启计算机后,防火墙默认已经开放了80和22端口

这里应该也可以不重启计算机:

#/etc/init.d/iptables restart

关闭防火墙服务即可:

时间: 2024-08-03 11:42:46

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防火墙对端口设置与查看

/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

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防火墙开放端口,针对固定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.在防火墙上添加端口 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 防火墙开端口(转)

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端口这条规则的下面 添加好之

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 防火墙实现端口转发、端口映射及双向通路

1. 允许数据包转发: #echo 1 > /proc/sys/net/ipv4/ip_forward 2. 转发TCP 8081到xx.xx.xx.xx: #iptables -t nat -I PREROUTING -p tcp -–dport 8081 -j DNAT –-to xx.xx.xx.xx 3. 使转发数据包实现"双向通路",给数据包设置一个正确的返回通道: #iptables -t nat -I POSTROUTING -p tcp -–dport 8081