PHP + Ipchains dynamically restrict internal Machine Access-Linux Enterprise Application-Linux server application information. The following is a detailed description. Sometimes, in order to make it easier for people in the same network segment to access the Internet, software is needed to dynamically control the network, but here we will introduce the implementation through PHP + Ipchains. First, we need to use Ipchains. For details about Ipchains, see ipchains getting started. We can use a rule to implement it, /sbin/ipchains-A input-s 192.168.1.103-j-DENY. In this way, the machine with the IP address 192.168.1.103 in the Intranet segment cannot go out of the network. If we write this command into the file, then it becomes dynamic through PHP modification. PHP to modify the file content. ";echo "";echo "";?> ";}?>其中 stop 文件存放的内容就是通过 PHP 来动态修改的 Ipchains 规则。注意:stop 文件的属性要修改,chmod 777 stop最后,修改 /etc/crontab 文件的内容。*/5 * * * * root /path/stop每隔五分钟执行 stop 文件的命令。当然,这样做也要一些弊端,第二次修改 stop 文件的内容时,需要把机器所有的 Ipchains 规则清空,如果本身网关机器本身就有 Ipchains 规则,就会把原先的 Ipchains 也清空,这时就需要把原有的ipchains也写到文件里去了。另外,如果加一个 shell ,当 stop 文件内容改变时才运行 crontab 里写 0/5 * * * * root /path/stop ,这样做就更好了。剩下的大家想想吧!:)
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