Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-24-2006, 09:11 AM
|
#1
|
Member
Registered: Jul 2005
Posts: 73
Rep:
|
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.
|
|
|
03-24-2006, 09:35 AM
|
#2
|
Member
Registered: Dec 2005
Distribution: RedHat, Ubuntu
Posts: 101
Rep:
|
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
|
|
|
03-24-2006, 11:17 AM
|
#3
|
Member
Registered: Jul 2005
Posts: 73
Original Poster
Rep:
|
Legend you are. Many thanks Pal.
|
|
|
03-24-2006, 12:04 PM
|
#4
|
Member
Registered: Jul 2005
Posts: 73
Original Poster
Rep:
|
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.
|
|
|
03-24-2006, 02:04 PM
|
#5
|
Member
Registered: Sep 2002
Posts: 310
Rep: 
|
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?
|
|
|
03-24-2006, 03:20 PM
|
#6
|
Member
Registered: Jul 2005
Posts: 73
Original Poster
Rep:
|
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?
|
|
|
03-24-2006, 04:40 PM
|
#7
|
Member
Registered: Sep 2002
Posts: 310
Rep: 
|
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.
|
|
|
03-25-2006, 04:14 AM
|
#8
|
Member
Registered: Jul 2005
Posts: 73
Original Poster
Rep:
|
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?
|
|
|
All times are GMT -5. The time now is 04:22 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|