Jump to content

PHP exec() not working properly


opencombatclan

Recommended Posts

I am trying to get my php firewall script to work.

I use the following code:

<?php
$ip1 = "123.123.123.123";
exec("iptables -A INPUT -s $ip1 -j DROP 2>&1", $output);
print_r($output);
?>

But I get

iptables v1.3.5: can't initialize iptables table `filter': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded

When I do exec("ls -a 2>&1", $output); it works perfectly fine.

I have no idea how to solve it. The php file is chmodded to 777 and has owner: root

If I login on my ssh and execute the command thru putty it works perfectly fine!

 

I have no idea how to fix this, I slept a few nights but I cant come up with a good solution. I really hope you guys can help me out

 

Link to comment
https://forums.phpfreaks.com/topic/165953-php-exec-not-working-properly/
Share on other sites

PHP is actually executing the command.  The problem lies with the iptables setup.  If you control the server here is something that I found that may help:

 

http://www.linuxquestions.org/questions/linux-networking-3/iptables-v1.3.8-cant-initialize-iptables-table-filter-577212/

 

If you are hosted, you'll have to contact your host.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.