Port 25
I have a problem getting mail packets to go out with my present firewall setup.
What I have is a firewall that blocks/drops everything at the start and then it goes on to allow access through specific ports. For Port 25 or smtp to work, I have the following line which I was hoping to have mail coming and going with this statement. However, outgoing mail can go, but incoming has a problem:
/usr/sbin/iptables -A INPUT -p tcp --destination-port 25 -j ACCEPT
I also tried the following two lines to see if things would work but to no avail..:
iptables -A OUTPUT -o $INTERNET -p tcp -s $IPADDR --sport $UNPRIVPORTS \
--dport 25 -j ACCEPT
iptables -A INPUT -i $INTERNET -p tcp ! --syn --sport 25 -d $IPADDR \
--dport $UNPRIVPORTS -j ACCEPT
So, if I take the firewall down, mail comes and goes just great.. What am I not seeing here??
---
The big cities of America are becoming Third World countries.
-- Nora Ephron
Ted Gervais
Coldbrook Nova Scotia
Canada B4R1A7
Quoted 2 lines · Ted Gervais
I have a problem getting mail packets to go out with my present firewall setup.
is the mail server on a machine behind the firewall, or running on the firewall itself?
Quoted 7 lines
What I have is a firewall that blocks/drops everything at the start and then it goes on to allow access through specific ports. For Port 25 or smtp to work, I have the following line which I was hoping to have mail coming and going with this statement. However, outgoing mail can go, but incoming has a problem:
/usr/sbin/iptables-A INPUT -p tcp --destination-port 25 -j ACCEPT
this allows TCP port 25 connections to the firewall itself.
Quoted 5 lines
I also tried the following two lines to see if things would work but to no avail..:
iptables -A OUTPUT -o $INTERNET -p tcp -s $IPADDR --sport $UNPRIVPORTS \
--dport 25 -j ACCEPT
that allows the firewall itself to send TCP packets out interface $INTERNET with if the source IP is $IPADDR, source port is $UNPRIVPORTS and the destination port is 25.
Quoted 2 lines
iptables -A INPUT -i $INTERNET -p tcp ! --syn --sport 25 -d $IPADDR \
--dport $UNPRIVPORTS -j ACCEPT
allows TCP packets destined for the firewall itself inbound on interface $INTERNET with flag SYN unset out of SYN, ACK, and RST, a source port of 25, destination IP $IPADDR and a destination port of $UNPRIVPORTS
Quoted 2 lines
So, if I take the firewall down, mail comes and goes just great.. What am I not seeing here??
first off--let me introduce you to a rule that (IMHO) should be at the top of all your built-in filter chains (INPUT, OUTPUT, FORWARD):
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
which will eliminate things like mr. "iptables -A INPUT -i $INTERNET -p tcp ! --syn --sport 25 -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT" above...
second--if the mail server is running on a machine other than the firewall itself--you need to be added rules to the FORWARD chain of the filter table, not INPUT/OUTPUT.
all this (and much more) knowledge can dropped on a brother at:
http://iptables-tutorial.frozentux.net/iptables-tutorial.html
-j
--
"I bent my wookie."
--The Simpsons
Quoted 6 lines · Jason Opperisano
Quoted 2 lines · Ted Gervais
I have a problem getting mail packets to go out with my present firewall setup.
is the mail server on a machine behind the firewall, or running on the firewall itself?
On the firewall.
Quoted 10 lines
Quoted 8 lines
What I have is a firewall that blocks/drops everything at the start and then it goes on to allow access through specific ports. For Port 25 or smtp to work, I have the following line which I was hoping to have mail coming and going with this statement. However, outgoing mail can go, but incoming has a problem:
/usr/sbin/iptables-A INPUT -p tcp --destination-port 25 -j ACCEPTthis allows TCP port 25 connections to the firewall itself.
.
Quoted 10 lines
Quoted 6 lines
I also tried the following two lines to see if things would work but to no avail..:
iptables -A OUTPUT -o $INTERNET -p tcp -s $IPADDR --sport $UNPRIVPORTS \
--dport 25 -j ACCEPTthat allows the firewall itself to send TCP packets out interface $INTERNET with if the source IP is $IPADDR, source port is $UNPRIVPORTS and the destination port is 25.
.
Quoted 8 lines
Quoted 3 lines
iptables -A INPUT -i $INTERNET -p tcp ! --syn --sport 25 -d $IPADDR \
--dport $UNPRIVPORTS -j ACCEPTallows TCP packets destined for the firewall itself inbound on interface $INTERNET with flag SYN unset out of SYN, ACK, and RST, a source port of 25, destination IP $IPADDR and a destination port of $UNPRIVPORTS
Quoted 7 lines
Quoted 2 lines
So, if I take the firewall down, mail comes and goes just great.. What am I not seeing here??
first off--let me introduce you to a rule that (IMHO) should be at the top of all your built-in filter chains (INPUT, OUTPUT, FORWARD):
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Alright. I just added it to my script.
Quoted 8 lines
which will eliminate things like mr. "iptables -A INPUT -i $INTERNET -p tcp ! --syn --sport 25 -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT" above...
second--if the mail server is running on a machine other than the firewall itself--you need to be added rules to the FORWARD chain of the filter table, not INPUT/OUTPUT.
Nope. Same machine
Quoted 12 lines
all this (and much more) knowledge can dropped on a brother at:
http://iptables-tutorial.frozentux.net/iptables-tutorial.html
-j
--
"I bent my wookie."
--The Simpsons
---
The big cities of America are becoming Third World countries.
-- Nora Ephron
Ted Gervais
Coldbrook Nova Scotia
Canada B4R1A7
Quoted 11 lines · Ted Gervais
Quoted 6 lines · Jason Opperisano
Quoted 2 lines · Ted Gervais
I have a problem getting mail packets to go out with my present firewall setup.
is the mail server on a machine behind the firewall, or running on the firewall itself?
On the firewall.
k--here's the basic idea:
# allow established packets in iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# allow mail in iptables -A INPUT -p tcp --syn --dport 25 -j ACCEPT
# allow established packets out iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# allow mail out iptables -A OUTPUT -p tcp --syn --dport 25 -j ACCEPT
# allow dns lookups out iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
-j
--
"Well, I'm not calling you a liar, but... I can't think of a way to
finish that sentence."
--The Simpsons
Quoted 15 lines · Ted Gervais
I have a problem getting mail packets to go out with my present firewall setup.
What I have is a firewall that blocks/drops everything at the start and then it goes on to allow access through specific ports. For Port 25 or smtp to work, I have the following line which I was hoping to have mail coming and going with this statement. However, outgoing mail can go, but incoming has a problem:
/usr/sbin/iptables-A INPUT -p tcp --destination-port 25 -j ACCEPTI also tried the following two lines to see if things would work but to no avail..:
Quoted 8 lines
iptables -A OUTPUT -o $INTERNET -p tcp -s $IPADDR --sport $UNPRIVPORTS \
--dport 25 -j ACCEPT
iptables -A INPUT -i $INTERNET -p tcp ! --syn --sport 25 -d $IPADDR \
--dport $UNPRIVPORTS -j ACCEPTSo, if I take the firewall down, mail comes and goes just great.. What am I not seeing here??
It's very likely the other systems sending in e-mail are hanging waiting on ident, port 113, try either allowing ident to pass or setting a REJECT on attempts to that port and see if that helps, and you might well get hung with DNS lookups with newer sendmails. Make sure the sendmail server can reach out and touch the DNS tree.
Thanks,
Ron DuFresne
Signature · 11 lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
...Love is the ultimate outlaw. It just won't adhere to rules.
The most any of us can do is sign on as it's accomplice. Instead
of vowing to honor and obey, maybe we should swear to aid and abet.
That would mean that security is out of the question. The words
"make" and "stay" become inappropriate. My love for you has no
strings attached. I love you for free...
-Tom Robins <Still Life With Woodpecker>Quoted 5 lines · R. DuFresne
It's very likely the other systems sending in e-mail are hanging waiting on ident, port 113, try either allowing ident to pass or setting a REJECT on attempts to that port and see if that helps, and you might well get hung with DNS lookups with newer sendmails. Make sure the sendmail server can reach out and touch the DNS tree.
Ron has an excellent point here about IDENT. a "good Internet citizen" thing to do when running a mail server is to reject ident instead of dropping it:
iptables -A INPUT -p tcp --syn --dport 113 \
-j REJECT --reject-with tcp-reset-j
--
"Getting out of jury duty is easy. The trick is to say you're
prejudiced against all races."
--The Simpsons
Quoted 6 lines · Jason Opperisano
Ron has an excellent point here about IDENT. a "good Internet citizen" thing to do when running a mail server is to reject ident instead of dropping it:
iptables -A INPUT -p tcp --syn --dport 113 \ -j REJECT --reject-with tcp-reset
Isn't it advisable for every tcp port you want to block? I have some documentation that says that doing otherwise it's even bad for your network communications.
Regards.
Signature · 12 lines
Jose Maria Lopez Hernandez Director Tecnico de bgSEC [email protected] bgSEC Seguridad y Consultoria de Sistemas Informaticos http://www.bgsec.com ESPAÑA The only people for me are the mad ones -- the ones who are mad to live, mad to talk, mad to be saved, desirous of everything at the same time, the ones who never yawn or say a commonplace thing, but burn, burn, burn like fabulous yellow Roman candles. -- Jack Kerouac, "On the Road"
is NOTRACK modules the only way to avoid connection tracking?
Hello, i have a question about connection tracking.
if i have at least one iptables rule with -m state ,no matter in which chain,then the conntrack module gets loaded in all iptables hooks and thus all packets will be connection tracked, even if i need to track only a small subset of packets. This means that the only way to avoid connection tracking for most of packes is to use the NOTRACK module in raw table to match them. Is my understanding correct?
Or i can avoid connection tracking without the use of NOTRACK modules?
Thanks a lot
Piavlo Alexander
Re: is NOTRACK modules the only way to avoid connection tracking?
Quoted 2 lines · Alexander Piavka
Hello, i have a question about connection tracking.
Hi
Quoted 7 lines
if i have at least one iptables rule with -m state ,no matter in which chain,then the conntrack module gets loaded in all iptables hooks and thus all packets will be connection tracked, even if i need to track only a small subset of packets. This means that the only way to avoid connection tracking for most of packes is to use the NOTRACK module in raw table to match them. Is my understanding correct?
Yes. This is right. Keep in mind that conntrack is a hook in the packet traversal just like any other hooks (PREROUTING, INPUT, FORWARD, ...)
Usually, that's the first hook ever. But, with the raw table, there's a new hook registered before conntrack. That's why you can tell :
That packet which is not going to TCP X and host X, just don't track it (NOTRACK).
Quoted 1 line
Or i can avoid connection tracking without the use of NOTRACK modules?
Without NOTRACK, that's a no conntrack for all or conntrack for all condition. There's no beside.
Quoted 4 lines
Thanks a lot
Piavlo Alexander
HTH,
Samuel
Quoted 5 lines · Jose Maria Lopez
El dom, 06 de 02 de 2005 a las 22:03, Jason Opperisano escribió:
Quoted 4 lines
Ron has an excellent point here about IDENT. a "good Internet citizen" thing to do when running a mail server is to reject ident instead of dropping it:
Quoted 7 lines
Quoted 2 lines
iptables -A INPUT -p tcp --syn --dport 113 \ -j REJECT --reject-with tcp-resetIsn't it advisable for every tcp port you want to block? I have some documentation that says that doing otherwise it's even bad for your network communications.
I've never heard it is bad, but, te question is how nice one wishes to be to those trying to transgess your security profile. I tend to use alot of drops, especially for ports like ftp, telnet, some of the printer and shell exec ports, any ports trojans are fond of. The drop make the other end continue trying till the command/connect attepmt is either aborted or timesout, and with autoomated attacks, that can slow down the how little nasty prog. Kinder to me and my other servers, as well as others on the net when I can slow these things down some. Reject with rst, those are for the ports that you wish to treat the otherend nicely from.
Thanks,
Ron DuFresne
Signature · 11 lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
...Love is the ultimate outlaw. It just won't adhere to rules.
The most any of us can do is sign on as it's accomplice. Instead
of vowing to honor and obey, maybe we should swear to aid and abet.
That would mean that security is out of the question. The words
"make" and "stay" become inappropriate. My love for you has no
strings attached. I love you for free...
-Tom Robins <Still Life With Woodpecker>Quoted 9 lines · R. DuFresne
I've never heard it is bad, but, te question is how nice one wishes to be to those trying to transgess your security profile. I tend to use alot of drops, especially for ports like ftp, telnet, some of the printer and shell exec ports, any ports trojans are fond of. The drop make the other end continue trying till the command/connect attepmt is either aborted or timesout, and with autoomated attacks, that can slow down the how little nasty prog. Kinder to me and my other servers, as well as others on the net when I can slow these things down some. Reject with rst, those are for the ports that you wish to treat the otherend nicely from.
I don't have the documentation handy, but it said making just a DROP could lead you to being DOS attacked. Have anybody heard something about this?
Quoted 3 lines
Thanks,
Ron DuFresne
Regards.
Signature · 12 lines
Jose Maria Lopez Hernandez Director Tecnico de bgSEC [email protected] bgSEC Seguridad y Consultoria de Sistemas Informaticos http://www.bgsec.com ESPAÑA The only people for me are the mad ones -- the ones who are mad to live, mad to talk, mad to be saved, desirous of everything at the same time, the ones who never yawn or say a commonplace thing, but burn, burn, burn like fabulous yellow Roman candles. -- Jack Kerouac, "On the Road"
Quoted 3 lines · Jose Maria Lopez
I don't have the documentation handy, but it said making just a DROP could lead you to being DOS attacked. Have anybody heard something about this?
i propose that the exact opposite is true. why should i make my firewall undertake the effort of generating a RST packet for every yahoo on the Internet that wants to scan my IP range for TCP 139, 445, etc.
DROP-ing a packet doesn't take any real effort on the firewall's part; whereas generating a RST packet adds at least some overhead--which in the extreme case could be significant.
-j
--
"Here are your messages: 'You have thirty minutes to move your
car.' 'You have ten minutes to move your car.' 'Your car has been impounded.' 'Your car has been crushed into a cube.' 'You have thirty minutes to move your cube.'"
--The Simpsons
Quoted 9 lines · Jason Opperisano
i propose that the exact opposite is true. why should i make my firewall undertake the effort of generating a RST packet for every yahoo on the Internet that wants to scan my IP range for TCP 139, 445, etc.
DROP-ing a packet doesn't take any real effort on the firewall's part; whereas generating a RST packet adds at least some overhead--which in the extreme case could be significant.
-j
I see your point, but just googling a bit:
http://www.chiark.greenend.org.uk/~peterb/network/drop-vs-reject
so things are maybe somewhat more complex.
Regards.
Signature · 12 lines
Jose Maria Lopez Hernandez Director Tecnico de bgSEC [email protected] bgSEC Seguridad y Consultoria de Sistemas Informaticos http://www.bgsec.com ESPAÑA The only people for me are the mad ones -- the ones who are mad to live, mad to talk, mad to be saved, desirous of everything at the same time, the ones who never yawn or say a commonplace thing, but burn, burn, burn like fabulous yellow Roman candles. -- Jack Kerouac, "On the Road"
Quoted 5 lines · Jose Maria Lopez
I see your point, but just googling a bit:
http://www.chiark.greenend.org.uk/~peterb/network/drop-vs-reject
so things are maybe somewhat more complex.
i think it's really a matter of opinion. i happen to not agree with the author of the link you provided. that doesn't make me right, though.
-j
--
"Be careful when we capture him! We cannot claim the reward unless
we have 51% of the carcass"
--The Simpsons