Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-19-2006, 08:56 AM   #1
Registered: Apr 2006
Location: Portsmouth
Distribution: CentOS & Ubuntu
Posts: 49

Rep: Reputation: 15
Running iptables from PHP

Hi all,

Running Apache 2, i have a php webpage and i want to be able to enter in in a field press a submit button. Then when i press it i want to be able to ALLOW or BLOCK the ipaddress using iptables.

using BASH the command would be iptables -A INPUT -s -P ICMP -J DROP

i want to be able to do this in php i save the or any other address as a variable $ip_address and import it into the following code?

echo exec('iptables -A INPUT -s $ip_address -j DROP');

im not sure if this is the correct code, i want to be able to block or allow it then display the results on the wedpage.

the reason i am doing this is for a project and cannot be done any other way!

could someone shed some light i have spent hours on the web searching how to do this and with no luck, this is a last resort and would really appreciate the help, if offered.

kind regards
Old 04-20-2006, 06:52 AM   #2
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
The code you specified looks okay to me at first glance (I don't know much about IP tables, tho), but you will need to use double-quotes for your string if you want to include a $variable within it.

Hope that helps.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
running iptables from php rookiepaul Linux - Security 20 03-29-2006 08:28 PM
IPTABLES is running ? How? aurelio26 Linux - Newbie 7 11-20-2004 01:30 AM
Running nat with Iptables muppski Linux - Networking 1 11-10-2004 04:00 AM
php and iptables hkerssies Programming 3 10-22-2003 02:14 PM
Iptables with gShield running over it Belyle Linux - Newbie 3 04-17-2003 07:37 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration