Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-15-2006, 11:53 AM
|
#1
|
Member
Registered: Dec 2005
Posts: 47
Rep:
|
Firewall (iptables) blocking sendmail some how
Hello,
I have iptables set to accept input and output on port 25 (conf below for reference), yet for some reason when I have the firewall enabled, emails won't send.
Are there some other ports sendmail needs to send emails?
Thanks
IP tables set-up script
-----
Code:
*mangle
:PREROUTING ACCEPT [444:43563]
:INPUT ACCEPT [444:43563]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [402:144198]
:POSTROUTING ACCEPT [402:144198]
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
COMMIT
*filter
:INPUT DROP [1:242]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
:LOG_DROP - [0:0]
:LOG_ACCEPT - [0:0]
:icmp_packets - [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j LOG_ACCEPT
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A INPUT -s 127.0.0.1 -j ACCEPT
-A INPUT -p icmp -j icmp_packets
-A INPUT -j DROP
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A OUTPUT -d 127.0.0.1 -j ACCEPT
-A OUTPUT -p icmp -j icmp_packets
-A OUTPUT -j DROP
-A LOG_ACCEPT -j LOG --log-prefix "[IPTABLES ACCEPT] : " --log-tcp-options --log-ip-options
-A LOG_ACCEPT -j ACCEPT
-A icmp_packets -p icmp -m icmp --icmp-type 0 -j ACCEPT
-A icmp_packets -s 127.0.0.1 -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A icmp_packets -p icmp -m icmp --icmp-type 8 -j DROP
-A icmp_packets -p icmp -m icmp --icmp-type 3 -j ACCEPT
-A icmp_packets -p icmp -m icmp --icmp-type 11 -j ACCEPT
COMMIT
|
|
|
02-15-2006, 12:49 PM
|
#2
|
Member
Registered: Sep 2003
Location: UK
Distribution: I use 'em all ;-)
Posts: 275
Rep:
|
it's probably failing on DNS lookups.
-A INPUT -p udp --sport <nameserver> -j ACCEPT
-A OUTPUT -p udp --dport <nameserver> -j ACCEPT
|
|
|
02-15-2006, 02:49 PM
|
#3
|
Member
Registered: Dec 2005
Posts: 47
Original Poster
Rep:
|
?????
smtp is udp???
|
|
|
02-15-2006, 04:23 PM
|
#4
|
Member
Registered: Sep 2003
Location: UK
Distribution: I use 'em all ;-)
Posts: 275
Rep:
|
no, smtp is tcp.
DNS queries are udp.
Sorry, I typed the rules wrong. It should be:
-A INPUT -p udp --sport 53 -s <nameserver> -j ACCEPT
-A OUTPUT -p udp --dport 53 -d <nameserver> -j ACCEPT
|
|
|
02-16-2006, 10:26 AM
|
#5
|
Member
Registered: Dec 2005
Posts: 47
Original Poster
Rep:
|
I am an idiot. You are a genius.
I am an idiot. You are a genius.
I am an idiot. You are a genius.
I am an idiot. You are a genius.
I am an idiot. You are a genius.
Sorry about that last post. I thought you were high - I completely did not know what you meant. I didn't even think that mtas need to resolve domains.
Thank you very much for helping me out. This one was beginning to really frustrate me.
It seems to be working aok now.
|
|
|
02-16-2006, 10:30 AM
|
#6
|
Member
Registered: May 2002
Location: Canada
Distribution: Slackware, Mandriva, RedHat
Posts: 46
Rep:
|
Quote:
Originally Posted by Dudydoo
Sorry, I typed the rules wrong. It should be:
-A INPUT -p udp --sport 53 -s <nameserver> -j ACCEPT
-A OUTPUT -p udp --dport 53 -d <nameserver> -j ACCEPT
|
I see why you'd need to allow outbound dns requests, but what's with the INPUT rule? Why allow incoming connections from the nameserver?
|
|
|
02-16-2006, 10:35 AM
|
#7
|
Member
Registered: Oct 2003
Location: King George, VA
Distribution: RHEL/CentOS/Scientific/Fedora, LinuxMint
Posts: 370
Rep:
|
Quote:
Originally Posted by scorbett
I see why you'd need to allow outbound dns requests, but what's with the INPUT rule? Why allow incoming connections from the nameserver?
|
I would allow tcp as well for dns zone tranfers to work
-A INPUT -p tcp --sport 53 -s <nameserver> -j ACCEPT
-A OUTPUT -p tcp --dport 53 -d <nameserver> -j ACCEPT
|
|
|
02-16-2006, 12:45 PM
|
#8
|
Member
Registered: Sep 2003
Location: UK
Distribution: I use 'em all ;-)
Posts: 275
Rep:
|
Quote:
Originally Posted by scorbett
I see why you'd need to allow outbound dns requests, but what's with the INPUT rule? Why allow incoming connections from the nameserver?
|
To receive replies to the queries.
|
|
|
02-16-2006, 12:58 PM
|
#9
|
Member
Registered: May 2002
Location: Canada
Distribution: Slackware, Mandriva, RedHat
Posts: 46
Rep:
|
Quote:
Originally Posted by Dudydoo
To receive replies to the queries.
|
Oh... duh. Not enough caffeine this morning, I think! 
|
|
|
02-16-2006, 01:54 PM
|
#10
|
Moderator
Registered: May 2001
Posts: 29,417
|
it's probably failing on DNS lookups
If that's the case it should show from the maillog.
I would allow tcp as well for dns zone tranfers to work
I thought most won't allow that anymore from unauth'ed sources?..
To receive replies to the queries.
So your INPUT.*RELATED,ESTABLISHED rule is for what?
emails won't send
..also some remotes like to ident you.
Dropping TCP/113 won't fix it, -j REJECT will.
|
|
|
02-16-2006, 02:34 PM
|
#11
|
Member
Registered: Sep 2003
Location: UK
Distribution: I use 'em all ;-)
Posts: 275
Rep:
|
Quote:
Originally Posted by unSpawn
To receive replies to the queries.
So your INPUT.*RELATED,ESTABLISHED rule is for what?
|
Point taken. But if your output policy is DROP, you need:
iptables -A OUTPUT -p udp -m state --state NEW -j ACCEPT
|
|
|
02-16-2006, 02:55 PM
|
#12
|
Moderator
Registered: May 2001
Posts: 29,417
|
But if your output policy is DROP
Now *that* I missed reading, good one!
|
|
|
02-16-2006, 03:36 PM
|
#13
|
Member
Registered: Dec 2005
Posts: 47
Original Poster
Rep:
|
Also, someone pointed out to me that I needed to allow the required FORWARD packets when sending with apache/php (I think since its going from nobody@localhost -> localhost.localdomain -> (fqdn on net) ).
I notice there are four entries in the log for each email that is sent this method (apache/php). The first two seem to be almost the same and so do the last two. Is there some redundancy in the set-up - can this be done more directly?
Code:
Feb 16 10:18:48 host sendmail[15516]: k1GFImIq015516: from=nobody, size=2238, class=0, nrcpts=1, msgid=<200602161518.k1GFImIq015516@serverdomainname.com>, relay=nobody@localhost
Feb 16 10:18:48 host sendmail[15517]: k1GFImCj015517: from=<nobody@serverdomainname.com>, size=2465, class=0, nrcpts=1, msgid=<200602161518.k1GFImIq015516@serverdomainname.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Feb 16 10:18:48 host sendmail[15516]: k1GFImIq015516: to=test@test.com, ctladdr=nobody (99/99), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32238, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (k1GFImCj015517 Message accepted for delivery)
Feb 16 10:18:54 host sendmail[15519]: k1GFImCj015517: to=<test@test.com>, ctladdr=<nobody@serverdomainname.com> (99/99), delay=00:00:06, xdelay=00:00:06, mailer=esmtp, pri=122465, relay=TestsRelayServer.com. [A.B.C.D], dsn=2.0.0, stat=Sent (OK id=1F9ksr-0003Np-R8)
(Dispite my earlier stupidity I was astute to the point about the INPUT rule also wondering why that was necessary - but I thought maybe it was so because it is udp and that it does not establish a connections - just sends packets blindly.)
P.s. I've looked in a couple of places including the manual and I can't seem to find what the -m flag means/does? (but the manual is big and I don't know how to search in less 
Last edited by ganz_friedrich; 02-16-2006 at 03:40 PM.
|
|
|
All times are GMT -5. The time now is 12:33 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|