centos 7 防火墙设置 使用 iptables firewall-cmd 开放端口号
2017-06-09 09:59
489 查看
开放端口
# iptables -I INPUT -p tcp --dport 8888 -j ACCEPT
or
# firewall-cmd --add-port=8888/tcp --permanent # firewall-cmd --reload
关闭端口
# firewall-cmd --remove-port=8888/tcp --permanent # firewall-cmd --reload
查看已配置规则
# iptables -S INPUT -P INPUT ACCEPT -A INPUT -p tcp -m tcp --dport 8888 -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited
or
# firewall-cmd --list-ports 8888/tcp
查看配置文件
# cat /etc/sysconfig/iptables # sample configuration for iptables service # you can edit this manually or use system-config-firewall # please do not ask us to add additional ports/services to this default configuration *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT -A INPUT -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
保存规则
# service iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ 确定 ]
再次查看配置文件
# cat /etc/sysconfig/iptables | grep 8888 -A INPUT -p tcp -m tcp --dport 8888 -j ACCEPT
服务启动停止
启动# systemctl start iptables
or
# systemctl start firewalld
停止
# systemctl stop iptables
or
# systemctl stop firewalld
相关文章推荐
- CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
- CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables
- CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
- CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙,配置apache
- CentOS 7.0如何将iptables作为防火墙(默认使用的是firewall作为防火墙)
- centos中iptables和firewall防火墙开启、关闭、查看状态、基本设置等
- [CENTOS7] [IPTABLES] 卸载Firewall Id安装 IPTABLES及防火墙设置
- centos中iptables和firewall防火墙开启、关闭、查看状态、基本设置等
- Centos 7防火墙iptables开放指定端口(80)和设置ftp的方法
- centos中iptables和firewall防火墙开启、关闭、查看状态、基本设置等
- CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
- CentOS 7 设置iptables防火墙开放proftpd端口
- Centos iptables防火墙设置
- CentOS 7.0默认使用的是firewall作为防火墙
- centos 6.5 系统中iptables防火墙开放端口
- CentOS 7.0默认使用的是firewall作为防火墙。
- centos防火墙的设置(80、23、3306端口开放指定IP段)
- CentOS 6.5系统中iptables防火墙开放端口80 3306 22端口
- 设置CentOS防火墙开放端口
- CentOS 7.0默认使用的是firewall作为防火墙。