Linux firewall rules

Source: Internet
Author: User

View firewall status

Service Iptables Status

View current firewall rules

Iptables-l-N

Clears the rules for all rule chains in the preset table filter

Iptables-f

Vi/etc/sysconfig/iptables

-A input-p tcp-m state--state new-m TCP--dport 80-j ACCEPT add allow port through firewall and save/etc/init.d/iptables Save Restart Iptable s effective

Iptables-a input-p TCP--dport 22-j ACCEPT External Add temporary firewall rule fails after reboot

iptables-d input-p TCP--dport 22-j ACCEPT Delete temporary firewall rule

Iptables-a input-s 192.168.0.3-p tcp--dport 22-j ACCEPT #只允许该IP连接该机器22端口

PS: If you want to allow or restrict a certain IP address to be available 192.168.0.0/24 represents all IPs on the 192.168.0.1-255 side.

24 indicates the number of subnet masks. But remember to delete the line in the/etc/sysconfig/iptables.

-A input-p tcp-m TCP--dport 22-j ACCEPT because it means all addresses can be logged in.

Iptables-a input-p tcp–dport 21-j ACCEPT
Iptables-a input-p tcp–dport 20-j ACCEPT
#允许FTP服务的21和20端口

Restrict access to an IP

Iptables-i input-s ***.***.***.***-j DROP

Disable IP

iptables-d input-s ***.***.***.***-j DROP

Linux firewall rules

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.