CentOS7.3 install iptables and detailed use

CentOS7.3 install iptables and detailed usage#

Installation operation##

Check status

First check if iptables is installed

$ service iptables status

Install iptables

$ yum install iptables

Upgrade iptables

$ yum update iptables 

Install iptables-services

$ yum install iptables-services

Edit configuration

$ vi /etc/sysconfig/iptables-config

Add configuration###

iptables -I INPUT -p tcp --dport 5672-j ACCEPT
iptables -I INPUT -p tcp --dport 15672-j ACCEPT

Save configuration###

$ service iptables save

Read on for more operations

Restart service###

systemctl restart iptables.service

More detailed configuration rules##

Edit configuration

$ vi /etc/sysconfig/iptables-config

Rule operation###

View iptables existing rules

iptables -L -n

Allow all

iptables -P INPUT ACCEPT

Allow IO access

Allow data packets from the lo interface (local access)

iptables -A INPUT -i lo -j ACCEPT

Open port 443 (TCP)

iptables -A INPUT -p tcp --dport 443-j ACCEPT

Open port 443 (FTP)

iptables -A INPUT -p tcp --dport 443-j ACCEPT

Open port 80 (HTTP)

iptables -A INPUT -p tcp --dport 80-j ACCEPT

Open port 443 (HTTPS)

iptables -A INPUT -p tcp --dport 443-j ACCEPT

Allow ping

iptables -A INPUT -p icmp --icmp-type 8-j ACCEPT

Allow response

Allow the return data RELATED after accepting the request of the machine, which is set for FTP

iptables -A INPUT -m state --state  RELATED,ESTABLISHED -j ACCEPT

Discard all inbound

iptables -P INPUT DROP

Allow all outbound

iptables -P OUTPUT ACCEPT

Forward and discard

iptables -P FORWARD DROP

More common command operations##

Purge rules

iptables -F #Clear all default rules
iptables -X #Clear all custom rules
iptables -Z #All counters return to 0

Save configuration

$ service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

Open service

$ systemctl start  firewalld

Check status

$ service iptables status

Out of service

$ systemctl stop firewalld

Restart service

$ systemctl restart iptables.service

View rules

iptables -L -n

Mark display

$ iptables -L -n --line-numbers
Chain INPUT(policy ACCEPT)
num  target     prot opt source               destination         
1 ACCEPT     tcp  --0.0.0.0/00.0.0.0/0            tcp dpt:156722    ACCEPT     tcp  --0.0.0.0/00.0.0.0/0            tcp dpt:5672

Delete rule

iptables -D INPUT 1

Disable service

$ systemctl mask firewalld

boot

systemctl enable iptables.service 

Contact

Recommended Posts

CentOS7.3 install iptables and detailed use
Install and use docker under CentOS 6.8
CentOS7 install and use SQL Server
CentOS7 install iptables firewall
Detailed steps to install virtual machines with VMware 15 and use CentOS 8
How to install and use Docker on CentOS 7
How to install and use Composer on CentOS 8
How to install and use Curl on CentOS 8
centos7 install python3 and ipython
Know Linux and install CentOS
CentOs7.3 compile and install Nginx 1.9.9
CentOS 7 install Mono and MonoDevelop
CentOS6.5 install Java 8 and Tomcat8
Centos compile and install Git
Centos6.5 install and configure mongodb
centos7 kvm installation and use
CentOS7 install python3 and pip3
CentOS7 install OracleJDK and JRE
CentOS6.5 install Java 8 and Tomcat8
vmware install CentOS 7 detailed tutorial
CentOS6 install and crack Jira 7
CentOS6.5 install Java 8 and Tomcat8
CentOS7 postgresql installation and use
Centos7 compile and install ntp-4.2.8p11
CentOS 6.9 compile and install python
CentOS6 install and crack confluence
CentOS 6 compile and install python 3
CentOS6 install and crack Jira 7
Centos7 elk7.1.1 installation and use
How to install and use Cockpit on CentOS 8/RHEL 8
CentOS7 yum install and start mysql
Install and configure keepalived under CentOS 5.9
Install and use dig under ubuntu/debian
CentOS Yum compile and install MySQL 5.6
Compile and install LAMP under Centos 5.2
CentOS 8 install Git and basic configuration
Use Nginx and u under CentOS
CentOS 6.x compile and install Nginx
CentOS7 compile and install L(A|N)MP environment
CentOS quickly install Python3 and pip3
CentOS7 yum install and start mysql
CentOS6 mininal install CouchDB2 detailed version
CentOS 8 - install and configure NFS service
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
Centos7 uninstall openJdk, and install JDK1.8
Install Python3 and ansible under CentOS8
Centos 7 RAID 5 detailed explanation and configuration
1.5 Install Centos7
CentOS Minimal install and configure TIPS
Install Python3 and Py under CentOS7
Install and configure FreeIPA in Centos7
Linux CentOS6 compile and install Pyt
Use VMware15 to install Linux (CentOS6.5)
virtualBox install centos, and build tomcat
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
Detailed steps to install and configure k8s cluster in centos 7
Use CentOS 7.5 to uninstall the built-in jdk and install your own JDK1.8
Compile and install libmodbus library under CentOS7
Installation and use of Mysql under CentOS
CentOS7.5 source code compile and install mysql5.7.29
Centos7 compile and install MySQL8 problem record