Linux - SecurityThis 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.
I want to know how I can put in my rc.firewall script to disable an IP to get out. I don't want a certain IP to get out to the internet. How can I do this in my rc.firewall script?
Assuming that your linux box in question is acting as a router for the other machines, you can add an ipchains rule. Something like:
ipchains -A -i eth1 -o eth0 -j REJECT
where (-i eth1) is your internal NIC connected to the LAN and (-o eth1) is your external NIC connected to the internet.
-DISCLAIMER-
You definitely want to verify that rule as my memory of RH7.0 and ipchains is fading, but the general idea should work.
Maybe I'm missing something, but isn't that solution going to shut down ALL addresses? If I'm reading the orignal question correctly, the problem is to shut down a single IP address. In iptables I think something like:
iptables -A OUTPUT -s XXX.XXX.XXX.XXX -j REJECT
might work, but I don't know what the ipchains equivalent would be.
I just double checked and we're all wrong. The target chain is lower case in ipchains (He's using RH7.0). So:
ipchains -A output -s XXX.XXX.XXX.XXX -j REJECT
doh!
Last edited by Capt_Caveman; 03-18-2003 at 09:13 PM.
I just realized he's using the 2.4.17 kernel, so he might have iptables running after all. So don't mind me, I'm just going to go back to sniffing glue now.
No iptables and ipchains use slightly different syntax:
For iptables:
iptables -A OUTPUT -s XXX.XXX.XXX.XXX -j REJECT
For ipchains:
ipchains -A output -s XXX.XXX.XXX.XXX -j REJECT
Notice the difference. So the question really is are you running iptables or ipchains. RedHat7.0 used ipchains but if you really updated your kernel all the way to version 2.4.17 (which I personally think is kind of hard-core) you could be using iptables.
A couple of questions:
1. Are you using iptables or ipchains?
2. Are you doing any kind of forwarding or masquerading(NAT)?
3. Did you put that rule before or after your rule(s) that allows the other addresses through.
If you're doing any kind of forwarding or masquerading for your LAN addresses, it might be bypassing the OUTPUT chain. If so, add a rule before the forwarding or masquerading lines that specifically prohibits that address from going through.
If your forwarding for example:
iptables -A FORWARD -i eth1 -o eth0 -s xxx.xxx.xxx.xxx -j REJECT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
-or just this-
iptables -A FORWARD -i eth1 -o eth0 -s !xxx.xxx.xxx.xxx -j ACCEPT
If your using ipchains, the syntax will be different. Also, post the relevent iptables rules, network topology, etc. It's kind of hard to figure out what the problem is if we don't have know the whole picture.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.