Centos Firewall Configuration

Source: Internet
Author: User

1. Use the setup command

[1] Open a terminal window and enter the setup command

[[email protected] ~]# setup

[2] Select firewall configuration and run tool to go to the firewall configuration page.

[3] select Enabled to enable the firewall. If this option is not selected, enable it. Select customize for custom configuration.

[4] select the service port to be opened. In this example, select FTP and WWW (HTTP ). By default, the SSH service port is enabled for SSH remote login. If you configure a Linux server remotely, you must keep the SSH service port open and do not disconnect the path.

[5] After the configuration is completed, you can forward it to the end and save it. If there are other ports to be opened, there will also be a custom page in the middle. At the end of the page, select YES to overwrite the original settings and save the settings.

 

 

2. Command Line

[1] edit the firewall configuration. Port 21 and port 80 are the added FTP service and port 80.

[[email protected] ~]# vi /etc/sysconfig/iptables# Firewall configuration written by system-config-firewall# Manual customization of this file is not recommended.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT

[2] disable the Firewall Service (temporarily disable the Firewall Service. The Service will be automatically enabled after restart)

[[email protected] ~]# service iptables stopiptables: Flushing firewall rules:                         [  OK  ]iptables: Setting chains to policy ACCEPT: filter          [  OK  ]iptables: Unloading modules:                               [  OK  ]

[3] configuring the Firewall Service does not start up by default (if the server does not need a firewall)

[[email protected] ~]# chkconfig iptables off


Centos Firewall Configuration

Related Article

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.