LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 12-12-2004, 09:06 PM   #1
TastyWheat
Member
 
Registered: Aug 2003
Location: Texas
Distribution: Knoppix 5.0.1, Fedora Core 5
Posts: 66

Rep: Reputation: 15
Easy Way to Lock Internet Access


As of now if I want to lock down my pc (ie. stop all network traffic) I turn off my ethernet and loopback devices. This is a problem because getting them up in the first place is usually a pain in the ass.

What is an easy way to effectively stop all network traffic without actually turning off my network connections?
 
Old 12-12-2004, 11:06 PM   #2
jlangelier
Member
 
Registered: Jun 2003
Location: Denver, CO
Distribution: Debian
Posts: 95

Rep: Reputation: 15
I'm not sure, but this is how I would attempt it.

I have a 'firewall' script which has my IPCHAINS rules. Near the top of the script, it flushes all the rules, then installs all the rules in the script.

If I had to do what you wanted to do, I would write another IPCHAINS script which would deny everything, outgoing and ingoing.
 
Old 12-13-2004, 12:02 AM   #3
TastyWheat
Member
 
Registered: Aug 2003
Location: Texas
Distribution: Knoppix 5.0.1, Fedora Core 5
Posts: 66

Original Poster
Rep: Reputation: 15
Thanks for the suggestion. From what I can tell I managed to cut off all network traffic with these commands. From what I can tell either command does pretty much the same thing. Someone correct me if I'm wrong.
Code:
> iptables -I INPUT -j DROP
> iptables -I INPUT -j REJECT
These have to be at the top of the list. Hence the '-I' switch. Apparently the rules are processed from the bottom up. To get rid of the top line the command is:
Code:
> iptables -D INPUT
That removes the rule at the top. So if you're going to write a script to do this it's probably not a good idea to use that command. It might remove something important. From what I read though, if you restart all of the old rules will come back because they're built into the kernel.

A follow up question though. I noticed that I'm unable to ping my machine, probably due to one of the rules. I'd like to have that available because my machine is a server and I'd like to know when it's up and when it's not. Is there some kind of gaping security hole related to ICMP that I'm not aware of?
 
Old 12-13-2004, 06:21 AM   #4
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 69
[QUOTE]Originally posted by TastyWheat
From what I can tell either command does pretty much the same thing. Someone correct me if I'm wrong.
Code:
> iptables -I INPUT -j DROP
> iptables -I INPUT -j REJECT

These will both work, the DROP target is going to cause connection attempts to hang until the full protocol timeout is reached while with REJECT, you'll get an instant connection refused response. Also keep in mind that you'll be blocking local traffic on the box, so things like sendmail and Xwindows may act broken when you use either of those rules. If that is undesireable, then just specify the external interfaces that you'd like to block traffic on, or just use:
iptables -I INPUT -i ! lo -j DROP

These have to be at the top of the list. Hence the '-I' switch. Apparently the rules are processed from the bottom up.
Actually it's from the top down, so if you added that rule it would be inserted at the top of the chain and would be the very first rule in that chain processed. Keep in mind that -A and -I do opposite things, so to get an idea of the order that you're rules are processed, take a look at the output of iptables -vnL.

To get rid of the top line the command is:
Code:
> iptables -D INPUT
That removes the rule at the top. So if you're going to write a script to do this it's probably not a good idea to use that command. It might remove something important.

A much better way is to just delete that rule specifically. With iptables if you use "iptables -D INPUT" it will blindly delete the very first rule, but if you specify that exact rule that you want to delete then you don't need to know where it is in the firewall:
iptables -D INPUT -j DROP

I noticed that I'm unable to ping my machine, probably due to one of the rules.
Yes, your rule is blocking all incoming traffic regardless of protocol, so ping won't work. You can either add a rule allowing icmp, or just customize your drop rule to block everything but icmp. Like so:
iptables -I INPUT -i ! lo -p ! icmp -j DROP

That is a little bit of an ugli hack though (you're allowiing all kinds of icmp types). A better solution would be to just use two scripts, one with your normal firewall rules and one with your blocking rules. Then you can run each script as needed and can make your blocking solution a little more flexible. Make sure to put rules flushing all chains at the top of each script otherwise rules from one script will be piled onto rules from the other. If you wanted to completely block the flow of traffic, then I'd probably recommend a script that just takes the interfaces down completely and then brings them back up as needed (like the service network stop command or ifdown script), but since you want ping then that wouldn't work here.
 
  


Reply



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
Lock down all programs but internet browser masterlodi Linux - Security 2 03-01-2005 04:12 AM
Easy access to root - vulnerability? Gay R0b0t Linux - Software 5 02-21-2005 08:19 AM
An easy way to view MS Access tables? Jefficus Linux - General 1 12-09-2003 11:20 AM
Easy access to the Internet drabkin Linux - Newbie 10 11-26-2002 08:03 AM
Internet lock out loganwva Linux - Security 3 11-16-2002 06:24 AM

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

All times are GMT -5. The time now is 06:16 AM.

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