LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 12-16-2008, 07:31 AM   #1
rahuljethwa
LQ Newbie
 
Registered: Dec 2008
Posts: 9

Rep: Reputation: 0
iptables -- Transparent Proxy with port blocking.


hi,
Am testing linux with iptables to act as an internet gateway.

Squid as transparent proxy and iptables to redirent 80 to 3128 works.
Also trying to allow only used ports like 21,22,25,110..etc..works.
iptables -A INPUT -s 192.168.0.0/24 -p tcp --dport 'port no' -j ACCEPT
iptables -A INPUT -j DROP

But together they do not ....am i missing something.
this is wat i get after service iptables status

Table: filter
Chain INPUT (policy DROP)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
5 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:22
6 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:20
7 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:21
8 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:23
9 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:25
10 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:110
11 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:443
12 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:8080
13 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:465
14 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:995
15 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:5666
16 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:1248
17 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:12489
18 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:119
19 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:80
20 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spt:53
21 DROP all -- 0.0.0.0/0 0.0.0.0/0
22 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:3128

Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

Table: nat
Chain PREROUTING (policy ACCEPT)
num target prot opt source destination
1 REDIRECT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:80 redir ports 3128

Chain POSTROUTING (policy ACCEPT)
num target prot opt source destination
1 MASQUERADE all -- 192.168.1.0/24 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

Table: mangle
Chain PREROUTING (policy ACCEPT)
num target prot opt source destination

Chain INPUT (policy ACCEPT)
num target prot opt source destination

Chain FORWARD (policy ACCEPT)
num target prot opt source destination

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

Chain POSTROUTING (policy ACCEPT)
num target prot opt source destination
 
Old 12-17-2008, 12:38 AM   #2
camh
Member
 
Registered: Feb 2005
Distribution: Slack/Debian
Posts: 163
Blog Entries: 2

Rep: Reputation: 33
Code:
21 DROP all -- 0.0.0.0/0 0.0.0.0/0
22 ACCEPT tcp -- 192.168.0.0/24 0.0.0.0/0 tcp dpt:3128
I'd start here. You have a DROP all before the ACCEPT. The packet would drop on 21 and wouldn't make it to 22.
 
  


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
Squid transparent proxy with iptables cksoo Linux - Server 5 06-12-2008 03:53 AM
IPTABLES for squid (Transparent proxy) kool_kid Linux - Networking 14 10-29-2007 10:45 AM
Transparent Proxy on second machine (iptables problem) kc8khl Linux - Networking 1 10-13-2007 12:03 AM
Squid, transparent proxy for more them one port maginotjr Linux - Networking 0 09-19-2007 07:52 AM
Iptables+transparent Proxy seitan Linux - Networking 11 12-13-2004 08:42 PM


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