Centos7 iptables firewalld firewall and selinux configuration

A . Iptables firewall

1 . Basic Operations

# Check firewall status

service iptables status  

# Stop firewall

service iptables stop  

# Start the firewall

service iptables start  

# Reboot the firewall

service iptables restart  

# Permanently turn off the firewall

chkconfig iptables off  

# Permanently closed after restart

chkconfig iptables on

  

2 . Open 80 ports

vim /etc/sysconfig/iptables

# Add the following code

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

Save and exit reboot the firewall

service iptables restart

3.iptables configuration operation

Continued ...

Two, Firewall firewall

1 . Check firewall service status

systemctl status firewalld

Appears Active: active (running) cut highlighted it means is activated state.

Appears  Active: inactive (dead) in gray stop, look at the words will do.

2 . Check firewall status

firewall-cmd --state

3 . On, restart, shut down, firewalld.service service

# Open

service firewalld start

# Reboot

service firewalld restart

# Close

service firewalld stop

4 . Check the firewall rules

firewall-cmd --list-all

5 . Firewall open ports Close

# Query port is open

firewall-cmd --query-port=8080/tcp

# Open 80 ports

firewall-cmd --permanent --add-port=80/tcp

# Removal port

firewall-cmd --permanent --remove-port=8080/tcp

# Restart firewall ( after modifying the configuration to restart the firewall )

firewall-cmd --reload

 

# Parameter Description

. 1 , firwall-cmd : a Linux operation provides a firewall of a tool;

2 , --permanent : expressed to be sustained;

. 3 , --add-Port : port identifier is added;

 

Three .selinux

# View selinux state

[root@localhost ~]# getenforce

Enforcing

# Temporary closure selinux state

[root@localhost ~]# setenforce 0

[root@localhost ~]# getenforce

Permissive

# Permanently closed

[root@localhost ~]# vim /etc/sysconfig/selinux

SELINUX=enforcing 改为 SELINUX=disabled

 

Guess you like

Origin www.cnblogs.com/hszstudypy/p/11519513.html