LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 09-20-2008, 01:53 AM   #16
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380

Quote:
Originally Posted by sanjee View Post
I have tried transparent proxy and I have latest version of FEDORA . But its not working and showing error while putting in squid.conf
parseConfigFile: line 594 unrecognized: 'httpd_accel_host virtual'
parseConfigFile: line 595 unrecognized: 'httpd_accel_port 80'
parseConfigFile: line 596 unrecognized: 'httpd_accel_with_proxy on'
parseConfigFile: line 597 unrecognized: 'httpd_accel_uses_host_header on'
Unless you're using a really old Squid version, those lines aren't used to set transparent mode.

Instead, you just add the word transparent to the http_port line, like (for example):
Code:
http_port 192.168.1.1:3128 transparent

Last edited by win32sux; 09-20-2008 at 01:55 AM.
 
Old 09-20-2008, 02:17 AM   #17
sanjee
Member
 
Registered: Jul 2008
Posts: 129

Original Poster
Rep: Reputation: 15
Yes I have tried also , but same error is coming . Should I load any module for that or anything related to http protocol (port 80)
 
Old 09-20-2008, 05:01 AM   #18
nowshining
Member
 
Registered: Dec 2007
Distribution: Ibex
Posts: 93

Rep: Reputation: 15
Quote:
Originally Posted by win32sux View Post
The reason you can't use iptables is because Gmail (for example) has thousands of IP addresses and they change all the time. A proxy is the right tool for the job. You can prevent people from bypassing it by disabling forwarding or by enforcing its use in transparent mode.

Threads with zero replies are automatically bumped. Don't do this - it's rude.
no not necessary altho a proxy can help google pretty much has a set range of ips for now... you just to drop the ip range from gmail....

And yes i know there are other countries, but if one does a search on the net one should be able to find the ips google uses, for example i've already got a lot of them.. again just a search over the net should do one good and of course and then once you've got an ip, whois that ip and find the range and use ipcalc to calculate the ip range from oh say 127.0.0.1 - 127.255.255.255..
 
Old 09-20-2008, 05:29 AM   #19
sanjee
Member
 
Registered: Jul 2008
Posts: 129

Original Poster
Rep: Reputation: 15
OK...I have a plan.
In user's web browser internet connection setting portion , will put Squid system IP & Port . So that users will browse internet through that method .
Now issue with remote mail server access (mail send / receive) & remote FTP server access (upload / download / login) . This could be solved..... If we can make proper NAT / Masquerade between local LINUX system & remote server's related ports.
But may be problematic.......if remote IP information is blocked , then its not possible to get remote IP .
Masquerade to all packet would make a security hole and pass all packet that will come to the interface . Now have to find out some exceptional IPTABLES rule , so that that would not create such security related problem.

Last edited by sanjee; 09-20-2008 at 05:33 AM.
 
Old 09-20-2008, 03:57 PM   #20
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by sanjee View Post
Yes I have tried also , but same error is coming . Should I load any module for that or anything related to http protocol (port 80)
That doesn't make sense. The error would not appear unless you still have those lines in there.

And no, there's no module you need to load.

Quote:
Originally Posted by sanjee View Post
OK...I have a plan.
In user's web browser internet connection setting portion , will put Squid system IP & Port . So that users will browse internet through that method .
Now issue with remote mail server access (mail send / receive) & remote FTP server access (upload / download / login) . This could be solved..... If we can make proper NAT / Masquerade between local LINUX system & remote server's related ports.
But may be problematic.......if remote IP information is blocked , then its not possible to get remote IP .
Masquerade to all packet would make a security hole and pass all packet that will come to the interface . Now have to find out some exceptional IPTABLES rule , so that that would not create such security related problem.
I don't really understand why you are making this sound so complicated. It's actually pretty simple. You proxy Web traffic (whether you do it transparently or not is irrelevant), and then NAT traffic to other specific ports (FTP, POP3, etc). You don't need to do masquerading for "all packets" or anything like that.
 
Old 09-22-2008, 12:40 AM   #21
sanjee
Member
 
Registered: Jul 2008
Posts: 129

Original Poster
Rep: Reputation: 15
Yes you r write . But problem arise when we don't know the actual port . Its possible the port number is statically or dynamically changed . Then Its difficult to nat with the port . And I m facing such kind of problem.I m unable to login some that kind of FTP servers due to port problem.
Would anyone help me how to NAT / MASQUERADE anything in this kind of situation .

Suppose Eth0 -> LAN & Eth1 -> Internet Connection . Now want login / Upload / Download to remote FTP server. Now Problem is that I don't know server's IP . BEcause said server's admin block ip information and change FTP port number.I know only domain name . Here how users will access those servers through linux firewall. But I don't want to masquerade all packets , because it will make security hole.

Regarding the problem I m confuse , how to make NAT / MASQUERADE with port 20,21 port to the changing/unknown ports .

Last edited by sanjee; 09-22-2008 at 12:42 AM.
 
Old 09-22-2008, 02:05 AM   #22
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by sanjee View Post
Yes you r write . But problem arise when we don't know the actual port . Its possible the port number is statically or dynamically changed . Then Its difficult to nat with the port . And I m facing such kind of problem.I m unable to login some that kind of FTP servers due to port problem.
Would anyone help me how to NAT / MASQUERADE anything in this kind of situation .

Suppose Eth0 -> LAN & Eth1 -> Internet Connection . Now want login / Upload / Download to remote FTP server. Now Problem is that I don't know server's IP . BEcause said server's admin block ip information and change FTP port number.I know only domain name . Here how users will access those servers through linux firewall. But I don't want to masquerade all packets , because it will make security hole.

Regarding the problem I m confuse , how to make NAT / MASQUERADE with port 20,21 port to the changing/unknown ports .
It would be extremely unusual for an admin to make an FTP daemon listen on a port other than 21. You don't ever need to worry about port 20, or any of the ephemeral (dynamically changing) ports - it's all handled by the module-provided FTP connection tracking.
 
Old 09-22-2008, 08:38 PM   #23
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
I wrote an example iptables script for you to help you get started. Here it is:
Code:
#!/bin/sh

IPT="/sbin/iptables"
LAN_IFACE="eth0"
LAN_NET="192.168.1.0/24"
WAN_IFACE="eth1"
DNS1="208.67.222.222"
DNS2="208.67.220.220"

$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT ACCEPT

$IPT -t nat -P PREROUTING ACCEPT
$IPT -t nat -P POSTROUTING ACCEPT
$IPT -t nat -P OUTPUT ACCEPT

$IPT -t mangle -P PREROUTING ACCEPT
$IPT -t mangle -P INPUT ACCEPT
$IPT -t mangle -P FORWARD ACCEPT
$IPT -t mangle -P OUTPUT ACCEPT
$IPT -t mangle -P POSTROUTING ACCEPT

$IPT -t raw -P PREROUTING ACCEPT
$IPT -t raw -P OUTPUT ACCEPT

$IPT -F
$IPT -F -t nat
$IPT -F -t mangle
$IPT -F -t raw

$IPT -X
$IPT -X -t nat
$IPT -X -t mangle
$IPT -X -t raw

$IPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

$IPT -A INPUT -i lo -j ACCEPT

# This is for Squid:
$IPT -A INPUT -p TCP -i $LAN_IFACE --dport 3128 \
-s $LAN_NET -m state --state NEW -j ACCEPT

# This is so that LAN clients can ping you:
$IPT -A INPUT -p ICMP -i $LAN_IFACE --icmp-type 8 \
-s $LAN_NET -m state --state NEW -j ACCEPT

$IPT -A INPUT -j LOG --log-prefix "INPUT DROP: "

$IPT -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

# This is for FTP (in case you don't wanna do it through Squid):
$IPT -A FORWARD -p TCP -i $LAN_IFACE -o $WAN_IFACE -s $LAN_NET \
--dport 21 -m state --state NEW -j ACCEPT

# This is for POP3:
$IPT -A FORWARD -p TCP -i $LAN_IFACE -o $WAN_IFACE -s $LAN_NET \
--dport 110 -m state --state NEW -j ACCEPT

# This is for DNS:
$IPT -A FORWARD -p UDP -i $LAN_IFACE -o $WAN_IFACE -s $LAN_NET \
-d $DNS1 --dport 53 -m state --state NEW -j ACCEPT

# This is for DNS:
$IPT -A FORWARD -p UDP -i $LAN_IFACE -o $WAN_IFACE -s $LAN_NET \
-d $DNS2 --dport 53 -m state --state NEW -j ACCEPT

$IPT -A FORWARD -j LOG --log-prefix "FORWARD DROP: "

$IPT -t nat -A POSTROUTING -o $WAN_IFACE -j MASQUERADE
It lets clients connect to Squid on the LAN, and it lets them connect to FTP, POP3, and DNS on the WAN. They would only be able to do HTTP/HTTPS through Squid, so you can determine which sites they can (or can't) use in your squid.conf by way of ACLs. You would, of course, need to customize this script before using it.

Last edited by win32sux; 09-22-2008 at 08:46 PM. Reason: Had forgotten POSTROUTING rule.
 
Old 09-23-2008, 12:05 AM   #24
sanjee
Member
 
Registered: Jul 2008
Posts: 129

Original Poster
Rep: Reputation: 15
So many Thanks. Till now I have tried with squid entry only etc. Its working fine.
BUT...BUT...BUT......again a small hole breaking squid web security . In mozilla or such type of browsers ,,,, from "preference" / "tools-> options (in XP)" portion there is a proxy bypass portion or "no proxy" option. I have chacked the domain name we put in the option . Its bypassing the squid security .

Is there any way to fight with it.
 
Old 09-23-2008, 02:18 AM   #25
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by sanjee View Post
So many Thanks. Till now I have tried with squid entry only etc. Its working fine.
BUT...BUT...BUT......again a small hole breaking squid web security . In mozilla or such type of browsers ,,,, from "preference" / "tools-> options (in XP)" portion there is a proxy bypass portion or "no proxy" option. I have chacked the domain name we put in the option . Its bypassing the squid security .
That means you're forwarding HTTP/HTTPS packets (which defeats the purpose of using Squid). Notice how, in the script I posted, no HTTP/HTTPS packets are forwarded - which makes the proxy bypass method you mention futile.
Quote:
Is there any way to fight with it.
Yes, stop forwarding TCP packets with destination ports 80 and 443.

Last edited by win32sux; 09-23-2008 at 02:32 AM.
 
Old 09-23-2008, 03:06 AM   #26
sanjee
Member
 
Registered: Jul 2008
Posts: 129

Original Poster
Rep: Reputation: 15
Yes ....the configuration you posted , its very nice. And I m trying to do according to your conf , because I m not so familier with IPTABLES Connection tracking rules.
Now I want to resolve my one query . The above mentioned problem I mentioned ,
in XP mozilla / other browsers [preference->connection setting > no proxy for... / tools -> options -> Advanced -> network -> settings -> no proxy for...]how redirecting web packets , because I m already been redirected port 80 to squid port like

-A FORWARD -i $LAN-interface -j ACCEPT
-A PREROUTING -i $LAN-interface -p tcp -m tcp --dport 80 -j DNAT --to-destination $squidip:squidport
-A PREROUTING -i $WAN-interface -p tcp -m tcp --dport 80 -j REDIRECT --to-ports $squidport
-A POSTROUTING -o $WAN-interface -j MASQUERADE
.........could you please make me clear what is my actual fault entry or is it passing https etc.

Last edited by sanjee; 09-23-2008 at 03:07 AM.
 
Old 09-23-2008, 01:00 PM   #27
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by sanjee View Post
Yes ....the configuration you posted , its very nice. And I m trying to do according to your conf , because I m not so familier with IPTABLES Connection tracking rules.
Now I want to resolve my one query . The above mentioned problem I mentioned ,
in XP mozilla / other browsers [preference->connection setting > no proxy for... / tools -> options -> Advanced -> network -> settings -> no proxy for...]how redirecting web packets , because I m already been redirected port 80 to squid port like

-A FORWARD -i $LAN-interface -j ACCEPT
-A PREROUTING -i $LAN-interface -p tcp -m tcp --dport 80 -j DNAT --to-destination $squidip:squidport
-A PREROUTING -i $WAN-interface -p tcp -m tcp --dport 80 -j REDIRECT --to-ports $squidport
-A POSTROUTING -o $WAN-interface -j MASQUERADE
.........could you please make me clear what is my actual fault entry or is it passing https etc.
HTTPS uses TCP destination port 443. HTTPS isn't transparently proxied by Squid. You need to add a rule to prevent TCP destination port 443 packets from being forwarded. Or better yet, set your FORWARD policy to DROP and only make rules for specific ports on the WAN which you want to allow your LAN clients to connect to (such as is done in my example). BTW, unless I'm missing something, at least one of the rules you posted doesn't make sense. I mean, why would you need both DNAT and REDIRECT? And why are you using REDIRECT on the WAN interface? Please explain.

AFAICT, you should be fine with something like this:
Code:
#!/bin/sh

IPT="/sbin/iptables"
LAN_IFACE="eth0"
LAN_NET="192.168.1.0/24"
LAN_IP="192.168.1.1"
WAN_IFACE="eth1"
DNS1="208.67.222.222"
DNS2="208.67.220.220"
SQUID_PORT="3128"

$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT ACCEPT

$IPT -t nat -P PREROUTING ACCEPT
$IPT -t nat -P POSTROUTING ACCEPT
$IPT -t nat -P OUTPUT ACCEPT

$IPT -t mangle -P PREROUTING ACCEPT
$IPT -t mangle -P INPUT ACCEPT
$IPT -t mangle -P FORWARD ACCEPT
$IPT -t mangle -P OUTPUT ACCEPT
$IPT -t mangle -P POSTROUTING ACCEPT

$IPT -t raw -P PREROUTING ACCEPT
$IPT -t raw -P OUTPUT ACCEPT

$IPT -F
$IPT -F -t nat
$IPT -F -t mangle
$IPT -F -t raw

$IPT -X
$IPT -X -t nat
$IPT -X -t mangle
$IPT -X -t raw

$IPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

$IPT -A INPUT -i lo -j ACCEPT

# This is for Squid:
$IPT -A INPUT -p TCP -i $LAN_IFACE --dport $SQUID_PORT \
-s $LAN_NET -m state --state NEW -j ACCEPT

# This is so that LAN clients can ping you:
$IPT -A INPUT -p ICMP -i $LAN_IFACE --icmp-type 8 \
-s $LAN_NET -m state --state NEW -j ACCEPT

$IPT -A INPUT -j LOG --log-prefix "INPUT DROP: "

$IPT -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

# This is for FTP (in case you don't wanna do it through Squid):
$IPT -A FORWARD -p TCP -i $LAN_IFACE -o $WAN_IFACE -s $LAN_NET \
--dport 21 -m state --state NEW -j ACCEPT

# This is for POP3:
$IPT -A FORWARD -p TCP -i $LAN_IFACE -o $WAN_IFACE -s $LAN_NET \
--dport 110 -m state --state NEW -j ACCEPT

# This is for DNS:
$IPT -A FORWARD -p UDP -i $LAN_IFACE -o $WAN_IFACE -s $LAN_NET \
-d $DNS1 --dport 53 -m state --state NEW -j ACCEPT

# This is for DNS:
$IPT -A FORWARD -p UDP -i $LAN_IFACE -o $WAN_IFACE -s $LAN_NET \
-d $DNS2 --dport 53 -m state --state NEW -j ACCEPT

$IPT -A FORWARD -j LOG --log-prefix "FORWARD DROP: "

$IPT -t nat -A PREROUTING -p TCP -i $LAN_IFACE -s $LAN_NET --dport 80 \
-d ! $LAN_IP -j REDIRECT --to-ports $SQUID_PORT

$IPT -t nat -A POSTROUTING -o $WAN_IFACE -j MASQUERADE

Last edited by win32sux; 09-23-2008 at 01:03 PM.
 
Old 09-24-2008, 02:38 AM   #28
sanjee
Member
 
Registered: Jul 2008
Posts: 129

Original Poster
Rep: Reputation: 15
No , actually previously I was thinking I should redirect port 80 to squid port with REDIRECT parameter and with the concept of PREROUTING I used DNAT . But now I m getting something different concept about above rules . Because I wasn't familier with IPTABLES Connection tracking rules. Could you please tell me , what is actual negative side of my DNAT rule / can it create some problem.

Now I m thinking it differently . According to the posts/discussion till now it has the ability to make a maping between port 80 and SQUID. At the same time If I want , Internet users can browse internal WEB or access any internal server like mail etc etc , where as there is existing internal squid or other firewalling rules ; then how I will match both rules.
is it like this "$IPT -A INPUT -p TCP -i $WAN_IFACE --dport $LAN_PORT -s 0/0 -m state --state NEW -j ACCEPT" or may be adding some redirection rule along with this . If this rule is really bad/ fool type ,,, then requesting to rectify me.

Last edited by sanjee; 09-24-2008 at 02:41 AM.
 
Old 09-24-2008, 03:46 AM   #29
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Is this iptables machine the same one which is running Squid?

Or are you running Squid on a separate machine?
 
Old 09-24-2008, 04:23 AM   #30
sanjee
Member
 
Registered: Jul 2008
Posts: 129

Original Poster
Rep: Reputation: 15
No both are in separate system . One for squid proxy for internal users and other as Firewall for Internet user's packet query coming in .

Now It could be possible by using separate ISP or connected with squid system.If I connected with squid system , then how to set it.

Last edited by sanjee; 09-24-2008 at 04:35 AM.
 
  


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
HELP HELP -> Firewall and security Kamikazee Linux - Security 3 07-05-2005 01:56 AM
Firewall security question Tyir Linux - Security 13 02-07-2004 07:21 PM
Need help with firewall security ... linuxbee Linux - Networking 0 08-11-2003 07:39 AM
Security/Firewall?? Queue-Automator Linux - Security 8 01-13-2003 06:01 PM

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

All times are GMT -5. The time now is 11:05 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