prevent an IP to get out?
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. |
Missed the chain: -A OUTPUT
|
Whoops! Thought that didn't look right.
Thanks unSpawn. |
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. |
isn't that solution going to shut down ALL addresses?
Whoops! Thought that didn't look right. Thanks Hangdog42. :-] |
Yeah, just like we said in the first place:
iptables -A OUTPUT -s XXX.XXX.XXX.XXX -j REJECT ;) |
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! |
At least you spotted it...
|
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.
|
yep, I'm using iptables.
Would it still be the same manner? iptables versus ipchains?
|
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. |
Thanks, i'll give it a try tonight!!
I'll give it a try tonight, I'll update my results.
|
does not work.
I entered this command and they can still get through after I've rebooted.
|
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. |
All times are GMT -5. The time now is 04:47 AM. |