Shut down firewall in the CENTOS7 system and use iptables to manage the firewall

Source: Internet
Author: User
Tags iptables

In our daily server management, often unified firewall management forms, we often use is to close the iptables (CENTOS6. X), use a script to manage the firewall. If some systems are centos7, it is necessary to close the firewall firewall at the same time.
1. Turn off the system default firewall firewall

Systemctl Stop firewalld.service shutdown firewall
systemctl disable firewalld.service shutdown boot

2. Install Iptables

Yum install iptables 
yum install iptables-services
service iptables stop
chkconfig iptables off or Systemctl Disable Iptables.service boot off iptables

3. Edit Firewall Script

vim/bin/iptables.sh #!/bin/bash shoffice1=1.2.3.4/sbin/iptables-f/sbin/iptables-x/sbin/iptables-z/sbin/iptables- A input-i lo-j accept/sbin/iptables-a input-s 127.0.0.1-d 127.0.0.1-j ACCEPT #office/sbin/iptables-a input-s 1. 2.3.4-j accept/sbin/iptables-a input-m State--state related,established-j ACCEPT # #for Game #/sbin/iptables-a INP Ut-p TCP--dport 80-j ACCEPT #for allmsserver #other------------------#Yum iptables-a input-p tcp--sport 80-j acce PT iptables-a input-p tcp--sport 443-j ACCEPT #ntpdate/sbin/iptables-a input-p UDP--sport 123-j accept/sbin/ipt Ables-a input-p UDP--dport 123-j ACCEPT # #dns/sbin/iptables-a input-p tcp--sport 53-j accept/sbin/iptables-a I Nput-p UDP--sport 53-j ACCEPT # #icmp:/sbin/iptables-a input-p ICMP--icmp-type any-j ACCEPT ###-NET-SNMP Monitor # # #/sbin/iptables-a input-p UDP--dport 161-j ACCEPT ### end ###/sbin/iptables-a input-p tcp-j REJECT H tcp-reset/sbin/iptableS-a input-j drop/sbin/iptables-a forward-j DROP 

The

Edit completes execution./bin/iptables.sh, and then IPTABLES-NVL to see if it takes effect.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.