Configure iptables firewall in RedHatLinux

Source: Internet
Author: User
Generally, iptables is included in the Linux release. run # iptables -- version to check whether iptables is installed in the system to start iptables: # serviceiptablesstart to view iptables rule set # iptables -- list the iptables format for planning is not defined below: ChainINPUT (policyACCEPT) target & nbs in general, iptables is already included in the Linux release.
Run # iptables -- version to check whether iptables is installed in the system to start iptables:
# Service iptables start
View iptables rule set # iptables -- list
The following figure shows the iptables when no planning is defined:
Chain INPUT (policy ACCEPT)
Target prot opt source destination
Chain FORWARD (policy ACCEPT)
Target prot opt source destination
Chain OUTPUT (policy ACCEPT)
Target prot opt source destination: #/etc/init. d/iptables status. If a series of information is displayed, the firewall is enabled. The default MySQL port is 3306, And the Linux firewall is blocked by default. Check whether port 3306 is open: # lsof-I: 3306. if no display instructions not open [Linux community http://www.linuxidc.com] to access 3306 can be in two ways, one is to close the firewall, the other is to open the firewall port 3306. I. Open Port 3306: Method 1: # iptables-I INPUT-I eth0-p tcp -- dport 3306-j ACCEPT
# Iptables-I OUTPUT-o eth0-p tcp -- sport 3306-j ACCEPT: # iptables-I input-I eth0-p tcp -- dport 3306-j DROP
# Iptables-I OUTPUT-o eth0-p tcp -- sport 3306-j DROP and save
#/Etc/rc. d/init. d/iptables save Method 2: 1. Modify the/etc/sysconfig/iptables file and add the following line: -A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT and then restart the firewall: # service iptables restart 2. Disable the firewall: either: 1) effective after restart: # chkconfig iptables off (the corresponding firewall enabling command is: # chkconfig iptables on) 2) takes effect immediately, but the firewall will start again after restart: # service iptables stop (the corresponding firewall enabling command is: # service iptables start)

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.