Linux firewall configuration

Source: Internet
Author: User

Iptables is a built-in firewall in the Linux kernel that allows administrators to filter packets and NAT by setting table, chain, and related rules.
In general, the Iptables firewall is already built into CentOS 6 and other Linux versions, and the Iptables service is started by default.
Iptables is applied to IPV4, Ip6tables is required if you want to use IPV6.

To view the current firewall status:
Service Iptables Status
To turn on/off/restart the firewall:
Service Iptables Start/stop/restart
To view the current rules:
Iptables-l-N

Iptables-f to clear all rule chains in the preset table filter
Iptables-x Clear Preset table rules in user-defined chains in filter

Save the modified content to the/etc/sysconfig/iptables file:
/etc/rc.d/init.d/iptables Save


[[email protected] ~]# iptables-p INPUT DROP--Turn off data that is connected to this computer
[[email protected] ~]# iptables-p OUTPUT ACCEPT--Open data from this machine
[[email protected] ~]# iptables-p FORWARD DROP--Turn off the forwarding chain

To open a specific port number:
Iptables-a input-p TCP--dport 22-j ACCEPT
Iptables-a output-p TCP--sport 22-j ACCEPT
/etc/rc.d/init.d/iptables Save

Linux 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.