LinuxQuestions.org
Review your favorite Linux distribution.
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 05-09-2006, 05:36 AM   #1
branden_burger
Member
 
Registered: Dec 2004
Posts: 66

Rep: Reputation: 15
iptables rule clarification


Hello all.

Here's an iptables rule, which says to allow from 192.168.1.0/24 on my firewall/NAT/proxy box.

-A INPUT -s 192.168.1.0/255.255.255.0 -p tcp -m tcp --dport 3128 -j allowed

Now to be safe that only internal network traffic to squid is allowed, do I need to make sure that I also add an interface switch? I mean , do I need to do
-i eth(internal) ?

I mean, can there be packets out on the internet which claim to be from my internal network?

thanks,
branden_burger
 
Old 05-09-2006, 05:55 AM   #2
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 57
Normally you shouldn't see IANA reserved addresses (192.168.) on the internet, but you may depending on your ISP and how they have things configured. However, I'd still strongly recommend that you specify the internel interface switch in the iptables rule to prevent unauthorized proxying.
 
Old 06-02-2006, 02:00 AM   #3
huanvnn
LQ Newbie
 
Registered: May 2006
Posts: 20

Rep: Reputation: 0
i think in this situation,you don't need to add -i eth(internal interface) because in your iptables rule
-A INPUT -s 192.168.1.0/255.255.255.0 -p tcp -m tcp --dport 3128 -j allowed

the source of packet allowed is : 192.168.1.0/24 ,and this source address isn't public address ip so not any packet from outside (internet) can come to your squid
 
Old 06-02-2006, 04:14 AM   #4
evilDagmar
Member
 
Registered: Mar 2005
Location: Right behind you.
Distribution: NBG, then randomed.
Posts: 480

Rep: Reputation: 31
Quote:
Originally Posted by branden_burger
Hello all.

Here's an iptables rule, which says to allow from 192.168.1.0/24 on my firewall/NAT/proxy box.

-A INPUT -s 192.168.1.0/255.255.255.0 -p tcp -m tcp --dport 3128 -j allowed

Now to be safe that only internal network traffic to squid is allowed, do I need to make sure that I also add an interface switch? I mean , do I need to do
-i eth(internal) ?

I mean, can there be packets out on the internet which claim to be from my internal network?

thanks,
branden_burger
There could be, but enabling reverse-path filtering and/or the bogon filter will usually kill them off. Something's going to have to become severely broken for someone on the internet to be able to complete a TCP connection by spoofing a private network IP address, since as has been pointed out, these packets generally aren't allowed to cross the Internet--and your box is likely going to send it's handshake packets to your localnet instead of the Internet.

Note the usual suspects:

/proc/sys/net/ipv4/conf/eth0/rp_filter
/proc/sys/net/ipv4/conf/default/rp_filter
/proc/sys/net/ipv4/conf/all/rp_filter
/proc/sys/net/ipv4/conf/lo/rp_filter

Stuff 1's in whichever of these you feel necessary (I wouldn't mess with lo's tho') to enable it. What will happen then is each packet arriving on an interface will be looked at briefly and if it wasn't supposed to have come from there, it'll be destroyed. There's a more detailed explanation hiding in /usr/src/linux/Documentation.

A *better/faster* way to deal with this issue is to simply drop in a rule at the end of your generic "apply 'em to all interfaces" rules section that will jump traffic to a chain of rules meant just for that interface. When I last checked, specifying an interface on a rule will make it only match traffic on that interface, but potentially all traffic can waste CPU time *attempting* to match against it. This can reduce the amount of overhead your system has to deal with during periods of heavy network load depending on how elegantly you've created your rules. (Either way, a chain named input_eth0 is kind of hard to misinterpret if you're up late at night trying to troubleshoot something) You can then be as particular as you want about each individual interface and what rules you wish to apply to it.
 
Old 06-02-2006, 04:55 PM   #5
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 57
Quote:
Originally Posted by huanvnn
i think in this situation,you don't need to add -i eth(internal interface) because in your iptables rule
-A INPUT -s 192.168.1.0/255.255.255.0 -p tcp -m tcp --dport 3128 -j allowed

the source of packet allowed is : 192.168.1.0/24 ,and this source address isn't public address ip so not any packet from outside (internet) can come to your squid
IMHO, there is no good reason not to specify the interface here, especially since this is a squid proxy. By not doing so you are implicitly trusting that the IANA guidelines are strictly adhered to. In theory they should never be on the public internet, but in practice some ISPs use IANA private addresses for routers and other infrastructure. Plus in a shared subscriber line like cable internet, if you are on the same downstream network segment you'll very often see misconfigured systems using IANA reserved addresses which get filtered by upstream routers (sometimes). Along these lines, it's interesting to note that IANA reserved addresses make up a large number of the direct address resolution queries to the root DNS servers (which should *never* happen in theory...one because DNS is tiered and two because they're IANA reserved IPs). So I would strongly recommend specifying the interface or using rp_filter is a great idea as well.
 
  


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
What is it doing this iptables rule?? lanczer Linux - Security 1 02-24-2006 11:26 AM
clarification on a forum rule microsoft/linux LQ Suggestions & Feedback 14 02-06-2006 12:07 PM
help with iptables rule!! vishamr2000 Linux - Security 6 11-09-2005 05:34 AM
IPTables Rule... Grim Reaper Linux - Software 8 04-28-2003 12:20 PM
IPTABLES rule file (need help) chris200t Linux - Networking 5 11-11-2002 02:33 PM


All times are GMT -5. The time now is 02:39 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration