This is a discussion on Open Mail Ports within the Linux software forums, part of the Linux Getting Started category; Hello, This is my first post here, thanx to all of the stff of it. I have read the following ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
Hello,
This is my first post here, thanx to all of the stff of it. I have read the following article: http://www.cyberciti.biz/tips/linux-...uid-howto.html which is about making a transperent proxy using squid. Everything is fine and http is running wonderful, but the problem is how can I make clients who are connected to this server to send and recieve mail ? They are unable to do so now, I have tried alot of iptables rules still didn't get to the answer. Is there anyone who can help me ? Best Regards, ReMSiS |
| Sponsored Links | ||
|
|
|
||||
|
Assuming that eth0 (interface 0) connected to Internet and has 192.168.1.254 IP address.
Assuming that eth1 (interface 1) connected to LAN has 192.168.1.1 IP *** Following two ruleset for outgoing SMTP requests *** Iptables rules for eth0 SMTP outgoing client request to Internet Code:
iptables -A OUTPUT -p tcp -s 192.168.1.254 --sport 1024:65535 -d 0/0 --dport 25 -m state --state NEW,ESTABLISHED -jACCEPT iptables -A INPUT -p tcp -s 0/0 --sport 25 -d 192.168.1.254 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT Code:
iptables -t nat -A POSTROUTING -o eth0 -p tcp -s 192.168.1.0/24 --sport 1024:65535 -d 0/0 --dport 25 -j SNAT --to 192.168.1.254 iptables -A OUTPUT -p tcp -s 192.168.1.0/24 --sport 1024:65535 -d 0/0 --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -s 0/0 --sport 25 -d 192.168.1.0/24 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT eth0 SMTP incoming client request form Internet Code:
iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 192.168.1.254 --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.1.254 --sport 25 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT Code:
iptables -A INPUT -p tcp -s 192.168.1.0/24 --sport 1024:65535 -d 192.168.1.1 --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.1.1 --sport 25 -d 192.168.1.0/24 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT Hope this helps!
__________________
Rocky Jr. You may have my body & soul, but you will never touch my pride! If you have knowledge, let others light their candles at it. Certified to work on HP-UX / Sun Solaris / RedHat |
|
|||
|
Thanx rockdalinux for your support. I use eth0 for local with 192.168.0.1 for it and use 192.168.1.2 for eth1
How can I block the chatting ports like yahoo, msn messengers? and open pop3 110 ? |
|
||||
|
POP3 from Lan
Code:
iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 192.168.1.2 --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.1.2 --sport 110 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT Code:
iptables -A INPUT -p tcp -s 192.168.0.1/24 --sport 1024:65535 -d 192.168.1.2 --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.1.2 --sport 110 -d 192.168.0.1/24 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -s 192.168.0.1/24 --sport 1024:65535 -d 192.168.0.1 --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.0.1 --sport 110 -d 192.168.0.1/24 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT To block Yahoo, MSN use port number with iptables
__________________
Rocky Jr. You may have my body & soul, but you will never touch my pride! If you have knowledge, let others light their candles at it. Certified to work on HP-UX / Sun Solaris / RedHat |
|
|||
|
Ok lets finalize the case my script shall be like this:
Code:
SQUID_SERVER="192.168.0.1" INTERNET="eth1" LAN_IN="eth0" SQUID_PORT="3120" iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t mangle -F iptables -t mangle -X iptables -P INPUT DROP iptables -P OUTPUT ACCEPT iptables -A INPUT -i lo -j ACCEPT iptables -A OUTPUT -o lo -j ACCEPT iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT iptables -A INPUT -i $LAN_IN -j ACCEPT iptables -A OUTPUT -o $LAN_IN -j ACCEPT iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT iptables -A OUTPUT -p tcp -s 192.168.1.1 --sport 1024:65535 -d 0/0 --dport 25 -m state --state NEW,ESTABLISHED -jACCEPT iptables -A INPUT -p tcp -s 0/0 --sport 25 -d 192.168.1.1 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT iptables -t nat -A POSTROUTING -o eth1 -p tcp -s 192.168.0.0/24 --sport 1024:65535 -d 0/0 --dport 25 -j SNAT --to 192.168.1.1 iptables -A OUTPUT -p tcp -s 192.168.0.0/24 --sport 1024:65535 -d 0/0 --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -s 0/0 --sport 25 -d 192.168.0.0/24 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 192.168.1.1 --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.1.1 --sport 25 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -s 192.168.0.0/24 --sport 1024:65535 -d 192.168.0.1 --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.0.1 --sport 25 -d 192.168.0.0/24 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 192.168.1.2 --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.1.2 --sport 110 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -s 192.168.0.1/24 --sport 1024:65535 -d 192.168.1.2 --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.1.2 --sport 110 -d 192.168.0.1/24 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -s 192.168.0.1/24 --sport 1024:65535 -d 192.168.0.1 --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 192.168.0.1 --sport 110 -d 192.168.0.1/24 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT iptables -A INPUT -j LOG iptables -A INPUT -j DROP am I right or wrong ? |
|
|||
|
By the way the topology used is:
eth1 = 192.168.1.2 connected to internet by GW GW for eth1 = 192.168.1.1 eth0 = 192.168.0.1 connected to internet by proxy server Proxy = 192.168.0.1 |
|
|||
|
By the way yesterday it worked fine using the original script
Quote:
Today it stopped working. Now only the http is working mail and others are not !!! Any suggestions ? |
|
|||
|
The message I am getting when I try to send and retreive mail is:
Host lookup failed: mail.domain.com: Temporary failure in name resolution
__________________
LivE Free 0r DiE L!nux rul3z aLL |
|
|||
|
Ok I think I found the problem, when I was connecting from my PC on the LAN I didn't give the interface on it a DNS server IP. When I gave it a DNS Server IP which is a public IP everything went well which means that routing is working fine on my Squid Server.
The question now is: Is it right to give a DNS server IP ? or the Proxy Server must do the resolution stuff by contacting the GW ?
__________________
LivE Free 0r DiE L!nux rul3z aLL |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to open a port | fed111 | Web servers | 1 | 03-09-2008 12:26 AM |
| Plz help me to choose a Free Open source MAIL SERVER | kantijena | Mail Servers | 1 | 02-29-2008 08:01 PM |
| How to drop all ports except mentioned in script | deltamails | Networking, Firewalls and Security | 2 | 05-15-2007 01:54 PM |
| Linux : How do I verify which ports are listening? | sweta | Getting started tutorials | 0 | 07-30-2006 11:02 PM |
| Blocking ports in linux | raj | Linux software | 1 | 07-10-2006 08:31 PM |