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-06-2005, 09:17 AM   #1
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Rep: Reputation: 30
opening ports pop3, imap and https


Hi all,

I have setup a proxy server using squid. all the clients on my LAN connecto to the internet through this proxy. i can access websites (via port 80) but not imap and smtp server. my outlook client can't connect to them. I have looked through this forums for answers but to no avail. I have followed advices from this forum and others but my iptables script not working.
Code:
iptables -t nat -A POSTROUTING -o eth2 -p tcp --dport 143 -j SNAT --to xxx.xxx.xxx.xxx
iptables -t nat -A POSTROUTING -o eth2 -p tcp --dport 25 -j SNAT --to xxx.xxx.xxx.xxx
where xxx.xxx.xxx.xxx is my external IP for proxy server.

For the INPUT, OUTPUT and FORWARD chains, the default policy is ACCEPT. ANyone pls?
 
Old 09-06-2005, 09:42 AM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
I think you need to use --to-source rather than --to for SNAT.
 
Old 09-06-2005, 09:50 AM   #3
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Original Poster
Rep: Reputation: 30
well it is the short form for --to-source

http://www.netfilter.org/documentati...T-HOWTO-6.html
 
Old 09-06-2005, 10:00 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
And you want the packets to appear as if they came from the proxy?
 
Old 09-06-2005, 10:12 AM   #5
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Original Poster
Rep: Reputation: 30
yes. that's right. i just want the client to be able to connect to imap and smtp port of my outside servers.
 
Old 09-06-2005, 10:18 AM   #6
sin
LQ Newbie
 
Registered: Jun 2005
Location: UK
Distribution: Slackware
Posts: 28

Rep: Reputation: 15
This is the script i use, you will need to modify the eth adapters and subnet to get it working on your system

--

#!/bin/bash

ETH_INT=eth0
ETH_EXT=eth1
INTSUBNET=192.168.1.0/24

EXTERN_IP=`ifconfig $ETH_EXT | grep inet | cut -d : -f 2 | cut -d \ -f 1`

# enable NAT sharing

modprobe ipt_MASQUERADE

iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -t nat -A POSTROUTING -o $ETH_EXT -j SNAT --to $EXTERN_IP

# enable ip forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward


# unlock lo
iptables -A INPUT -i lo --src localhost -j ACCEPT


iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW --src $INTSUBNET -j ACCEPT


iptables -P INPUT DROP

--

you may also want to consider adding this if your using windows clients internally

--

MS_TCP="135","139","445","593"
MS_UDP="135","137","138","445"

iptables -A OUTPUT -o $EXT_ETH -p tcp -m multiport --dport $MS_TCP -j DROP
iptables -A OUTPUT -o $EXT_ETH -p udp -m multiport --dport $MS_UDP -j DROP

iptables -A INPUT -i $EXT_ETH -p tcp -m multiport --dport $MS_TCP -j DROP
iptables -A INPUT -i $EXT_ETH -p udp -m multiport --dport $MS_UDP -j DROP

--

helps stop them adding to the background noise on the inet :P


hope it helps
 
Old 09-06-2005, 11:08 AM   #7
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Original Poster
Rep: Reputation: 30
thanks. It is working. I just forgot to check the ip_forward. it was 0. after i set it to 1, it worked!
 
  


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
opening imap/pop3 server checkchan Programming 2 06-09-2004 09:17 AM
imap and pop3 won't start cmritter Linux - Networking 9 06-20-2003 06:16 PM
Question on Imap and Pop3 cojo Linux - Software 2 06-17-2003 09:51 AM
pop3 / imap daemon markus1982 Linux - Software 1 03-03-2003 03:06 PM
pop3 and imap configration tarak4u Linux - Networking 1 05-29-2002 04:54 AM

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

All times are GMT -5. The time now is 11:10 PM.

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