flyable heart 手机版:如何配置linux下的防火墙?
准备装有Linux系统的电脑。
1.在linux系统里面找到并打开编辑配置防火墙的文件,执行命令:
vi /etc/sysconfig/iptables。
2.在上面打开的文件里面加入一下语句:
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火墙)。
3.重启防火墙使配置生效语句service iptables restart。
4.查看防火墙规则是否生效。
扩展资料:
查看防火墙状态:
[root@cluster1 ~]# service iptables status
iptables:未运行防火墙。
开启防火墙:
[root@cluster1 ~]# service iptables start
关闭防火墙:
[root@cluster1 ~]# service iptables stop
1、首先需要在Linux系统中查找并打开文件以编辑和配置防火墙,执行命令: vi /etc/sysconfig/iptables。
2、然后将以下语句添加到上面打开的文件中:-A INPUT -m state -state NEW -m tcp -p tcp -dport 80 -j ACCEPT(允许端口80通过防火墙,这里以端口80为例)。
请注意,上述语句不会加载文件的最后一面,这将导致防火墙无法启动。 应将正确的一个添加到默认的22端口规则中。
3、配置防火墙规则
# Manual customization of this file is not recommended.
4、重启防火墙,使配置生效。
/etc/init.d/iptables restart或者service iptables restart
重启如下:
扩展资料:
查看防火墙规则是否生效:
[root@localhost bin]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
Linux下开启/关闭防火墙命令
1、永久性生效,重启后不会复原。
开启: chkconfig iptables on
关闭: chkconfig iptables off
2、 即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。
扩展资料
linux配置防火墙规则:
1、在Linux系统中查找并打开文件以编辑和配置防火墙,执行命令。: vi /etc/sysconfig/iptables。
2、将以下语句添加到上面打开的文件中:-A INPUT -m state -state NEW -m tcp -p tcp -dport 80 -j ACCEPT(允许端口80通过防火墙,这里以端口80为例)。
请注意,上述语句不会加载文件的最后一面,这将导致防火墙无法启动。 应将正确的一个添加到默认的22端口规则中。
3、配置防火墙规则
# Manual customization of this file is not recommended.
4、重启防火墙,使配置生效。
/etc/init.d/iptables restart或者service iptables restart
重启如下:
1、在Linux系统中查找并打开文件以编辑和配置防火墙,执行命令。: vi /etc/sysconfig/iptables。
2、将以下语句添加到上面打开的文件中:-A INPUT -m state -state NEW -m tcp -p tcp -dport 80 -j ACCEPT(允许端口80通过防火墙,这里以端口80为例)。
请注意,上述语句不会加载文件的最后一面,这将导致防火墙无法启动。 应将正确的一个添加到默认的22端口规则中。
3、配置防火墙规则
# Manual customization of this file is not recommended.
4、重启防火墙,使配置生效。
/etc/init.d/iptables restart或者service iptables restart
重启如下:
扩展资料:
查看防火墙规则是否生效:
[root@localhost bin]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
参考资料:百度百科-防火墙
1、在linux系统里面找到并打开编辑配置防火墙的文件,执行命令: vi /etc/sysconfig/iptables。
2、在上面打开的文件里面加入一下语句: -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火墙,这里以80端口为例)。
注意的是上面这条语句不要加载文件的最后面,这样会导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面。
3、设置防火墙规则
# Manual customization of this file is not recommended.
4、重启防火墙使配置生效
/etc/init.d/iptables restart或者service iptables restart
重启如下:
扩展资料:
查看防火墙规则是否生效:
[root@localhost bin]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination