LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 03-24-2006, 09:11 AM   #1
rookiepaul
Member
 
Registered: Jul 2005
Posts: 73

Rep: Reputation: 15
Blocking all traffic from a particular IP


I'm trying to block all traffic from a particular IP on my network to my unix box. I've tried the following commands:

iptables -A INPUT -s 192.168.0.6 -j DROP
iptables -A INPUT -j DROP -p tcp -s 192.168.0.6

When I view the iptables it says that it's blocked, but I am still able to ping and ssh into the unix box from 192.168.0.6.

What am I doing wrong?

Rookie.
 
Old 03-24-2006, 09:35 AM   #2
cconstantine
Member
 
Registered: Dec 2005
Distribution: RedHat, Ubuntu
Posts: 101

Rep: Reputation: 15
remember it matters where in the list of rules your 'drop' rules are positioned. If there is a rule earlier which is permitting the traffic, then those packets match there and are never tested against your 'drop' rule.

move your 'drop' rule (the -s foo w/o -p tcp is sufficient) to the top:

iptables -I INPUT 1 ...

that's a cap 'i'. The -A arg appends on the end of the list.

-c
 
Old 03-24-2006, 11:17 AM   #3
rookiepaul
Member
 
Registered: Jul 2005
Posts: 73

Original Poster
Rep: Reputation: 15
Legend you are. Many thanks Pal.
 
Old 03-24-2006, 12:04 PM   #4
rookiepaul
Member
 
Registered: Jul 2005
Posts: 73

Original Poster
Rep: Reputation: 15
Does anyone have any idea why this doesn't do anything to the iptable?

<HTML>
<BODY>
<?php
$source = $_POST["source"];
echo $source;
exec('iptables -I INPUT 1 -s 192.168.0.6 -j DROP');
?>
</BODY>
</HTML>

It doesn't add an entry to block 192.168.0.6.
 
Old 03-24-2006, 02:04 PM   #5
int0x80
Member
 
Registered: Sep 2002
Posts: 310

Rep: Reputation: Disabled
My guess is that the php script is not running as root... which is a good thing. What's wrong with adding the rule to iptables by hand?
 
Old 03-24-2006, 03:20 PM   #6
rookiepaul
Member
 
Registered: Jul 2005
Posts: 73

Original Poster
Rep: Reputation: 15
I'm creating a php frontend for iptables. I have added the sudo user www with all, but I still can't get it to work. Do I need to change what apache logs into the system as?
 
Old 03-24-2006, 04:40 PM   #7
int0x80
Member
 
Registered: Sep 2002
Posts: 310

Rep: Reputation: Disabled
Then you'll need to make your iptables calls using sudo with the user that the PHP script is running as. This is all a bad idea though in my opinion. You were warned, twice.
 
Old 03-25-2006, 04:14 AM   #8
rookiepaul
Member
 
Registered: Jul 2005
Posts: 73

Original Poster
Rep: Reputation: 15
Yeah I know it's a security issue, but it's for a University project, and it's going to be running in a virtual environment on a private network. How do I find out what php is running as?
 
  


Reply


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
iptables blocking traffic JJX Linux - Networking 4 11-07-2005 06:36 AM
Blocking traffic fugzi Linux - Networking 2 12-04-2004 04:31 PM
Blocking Traffic on a specific port (kazaa) GratePayne Linux - Security 4 05-09-2004 10:10 AM
Iptables blocking all traffic on other NIC spede Linux - Security 3 05-05-2004 06:37 PM
firewall traffic blocking help jaylee Linux - Security 8 06-30-2003 11:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:22 PM.

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