Configure iptables to open port 80

Source: Internet
Author: User
Iptables-F // clear rules iptables-AINPUT-ptcp -- dport22-jACCEPT/* allow packets from port 22 into */iptables-AOUTPUT-ptcp -- sport22-mstate -- stateESTABLISHED-jACCEPT/* allow from 22 port entry package return */iptables-AOUT Iptables-F // clear the rule
Iptables-a input-p tcp -- dport 22-j ACCEPT/* allow packets to enter from port 22 */
Iptables-a output-p tcp -- sport 22-m state -- state ESTABLISHED-j ACCEPT/* packets allowed to enter port 22 are returned */
Iptables-a output-p udp -- dport 53-j ACCEPT
Iptables-a input-p udp -- sport 53-j ACCEPT
Iptables-a input-s 127.0.0.1-d 127.0.0.1-j ACCEPT/* allow local access to the local machine */
Iptables-a output-s 127.0.0.1-d 127.0.0.1-j ACCEPT
Iptables-a input-p tcp-s 0/0 -- dport 80-j ACCEPT/* allow all IP addresses to access port 80 */
Iptables-a output-p tcp -- sport 80-m state -- state ESTABLISHED-j ACCEPT
Iptables-save>/etc/sysconfig/iptables/* save the configuration or use the command serviceiptables save */
Iptables-L
The 80 and 22 values can be abbreviated:
/Sbin/iptables-I INPUT-p tcp -- dport 80-j ACCEPT
/Sbin/iptables-I INPUT-p tcp -- dport 22-j ACCEPT
Disable 192.168.0.7 connection Memcached
Iptables-a input-s 192.168.0.7-p tcp -- dport 11211-j DROP
Only the specified ip address is allowed to access the specified port.
Iptables-a input-s 74.81274.142-p tcp -- dport 9306-jACCEPT
Iptables-a input-p tcp -- dport 9306-j DROP # if there is A rule at the bottom of the iptables table that rejects rules other than all rules, this line does not need to be written.

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.