Turn off the Linux firewall using the command line method

Source: Internet
Author: User

#/sbin/iptables-i input-p TCP--dport 80-j ACCEPT

#/sbin/iptables-i input-p TCP--dport 22-j ACCEPT  #/etc/rc.d/init.d/iptables save  After restarting the computer, The firewall has already opened 80 and 222 ports by default.   Temporarily shut down the firewall completely, can not restart the machine: #/etc/init.d/iptables status                # #查看防火墙状态 #/etc/init.d/iptable stop                   # #本次关闭防火墙 #/etc/init.d/iptable Res Tart                # #重启防火墙永久性关闭防火墙: #chkconfig--level iptables off   (note Two English small short-term; restart)  : Set the firewall open port method as follows: Vi/etc/sysconfig/iptables when modifying a firewall, it is best to leave VNC and SSH management ports.      Below is an example of a iptables: # Firewall configuration written by system-config-securitylevel# Manual Customization of this file was not recommended.*filter:input accept [0:0]:forward Accept [0:0]:output Accept [0:0]:rh-firew All-1-input-[0:0]-a input-j rh-firewall-1-input-a forward-j rh-firewall-1-input-a rh-firewall-1-input-i lo-j ACCEPT- A rh-firewall-1-input-p icmp–icmp-type any-j accept-a RH-FIREWALL-1-INPUt-p 50-j accept-a rh-firewall-1-input-p 51-j accept-a rh-firewall-1-input-m state–state established,related-j ACCE Pt-a rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 53-j accept-a rh-firewall-1-input-m state–state NEW- M udp-p udp–dport 53-j accept-a rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 22-j ACCEPT-A RH-Firewall -1-input-m state–state new-m tcp-p tcp–dport 25-j accept-a rh-firewall-1-input-m state–state new-m tcp-p TCP–DP ORT 80-j accept-a rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 443-j accept-a rh-firewall-1-input-j REJ Ect–reject-with Icmp-host-prohibitedcommit To modify this file according to their own needs, for example, if you do not want to open the 80 port to provide Web services, then you should delete this line:-A Rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 80-j Accept all modifications after you restart Iptables:service iptables restart you can verify Whether the rules are in effect: iptables-l So, we have completed the setup modification of the CentOS firewall.

Turn off the Linux firewall using the command line

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.