How to set open ports and save rules for iptables

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 research is complete

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.

Start the VM this morning and find that the test page is inaccessible. Use ps aux | grepNginxAnd ps aux | grepphp check that the processes are started, so it is suspected thatIptablesPlaying tricks. Use serviceIptablesAfter stopping iptables, 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.

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.