Iptables open port and Save settings

Source: Internet
Author: User

I have studied the lnmp one-click installation package of June, and want to streamline it and use it as my own installation and configuration script. I deleted a lot of interaction and judgment parts. Some others haven't understood them yet, but I probably know the functions. After running it on a new virtual machine, after more than an hour of installation, you can access the test page, and phpinfo page. After the study is complete, add comments and put them on.

Starting the virtual machine this morning, I found that the test page could not be accessed. I checked the processes with ps aux | grep nginx and ps aux | grep php and started them. I suspect iptables is playing tricks. After stopping iptables with service iptables stop, the test page can be accessed normally.

View iptables settings in the next one-click installation package

# Add 80 port to iptables
If [-s/sbin/iptables]; then
/Sbin/iptables-I INPUT-p tcp -- dport 80-j ACCEPT
/Sbin/iptables-save
Fi

There are indeed settings, but the settings are not saved.
Later, Google found a post with the settings

/Sbin/iptables-I INPUT-p tcp -- dport 80-j ACCEPT
/Sbin/iptables-I INPUT-p tcp -- dport 22-j ACCEPT
/Etc/rc. d/init. d/iptables save
/Etc/init. d/iptables restart

Reboot after resetting. Start up and access the test page. OK! The main difference is that the location of the iptables called during storage is different.

Recommended reading:

Linux Firewall iptables

Iptables + L7 + Squid implements a complete software firewall

Basic use of iptables backup, recovery, and firewall scripts

Detailed description of firewall iptables usage rules in Linux

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.