您的位置:首页 > 运维架构 > Linux

Linux防火墙和端口的关闭与开启

2018-03-11 23:44 281 查看
CentOS 是通过iptables来管理防护墙的对于防火墙的开启与关闭命令在网络上随处可见,我就简单的理一下,本文主要介绍开启和关闭端口
重启后生效
开启: chkconfig iptables on 
关闭: chkconfig iptables off 
即时生效,重启后失效
开启: service iptables start
关闭: service iptables stop
$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
$ sudo firewall-cmd --reload
$ firewall-cmd --list-all
CentOS/RHEL 6
$ sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
$ sudo service iptables save
$ sudo system-config-firewall-tui
[root@localhost michael]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@localhost michael]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:6379 
2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:6379 
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
4    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
5    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
6    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
7    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

在CentOS 6、 7两个不同的版本上开启端口的方法是不同的
开启一个端口CentOS/RHEL 7
[root@localhost michael]# 

未完待续。。。。。。。。。。。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: