Forum Discussion
Josh_Hildebran1
Nimbostratus
Jul 11, 2006SMTP EHLO response
I'd like to make an iRule that looks for a "EHLO " command and simply responds w/ a particular error message.
I've tried to piece together something, but I've come up short, apparently. Can anyone help?
rule FixUP-SMTP {
when CLIENT_ACCEPTED {
TCP::collect
TCP::release
}
when CLIENT_DATA {
set sdata [TCP::payload]
if { $sdata starts_with "EHLO " } {
TCP::respond "500 5.3.3 Unrecognized command\r\n"
reject
} else {
TCP::release
TCP::collect
}
}
}
- Josh_Hildebran1
Nimbostratus
Hmm.. Thanks for the pointers. Unfortunately, it's still not doing what I need.virtual smtptest_from_internal { destination 172.20.140.26:smtp ip protocol tcp pool smtp_testpool rule FixUP-SMTP vlans internal enable }
rule FixUP-SMTP { when CLIENT_ACCEPTED { TCP::collect} when CLIENT_DATA { if { [TCP::payload] contains "EHLO " } { TCP::respond "500 5.3.3 Unrecognized command\r\n" reject } TCP::release } }
220 ********************************* EHLO EXDEMO 502 Error: command not implemented
- Colin_Walker_12Historic F5 AccountHave you tried moving the status code outside of the quotes on the TCP::respond line?
when CLIENT_ACCEPTED { TCP::collect } when CLIENT_DATA { if { [TCP::payload] contains "EHLO " } { TCP::respond 500 "5.3.3 Unrecognized command\r\n" reject } TCP::release }
- rapmaster_c_127Historic F5 AccountTry this:
rule FixUP-SMTP { when SERVER_CONNECTED { peer { TCP::collect } } when CLIENT_DATA { if { [TCP::payload] starts_with "EHLO" } { TCP::respond "500 5.3.3 Unrecognized command\r\n" set len [TCP::payload length] TCP::payload replace 0 $len "" TCP::release } else { TCP::release TCP::collect } } }
- rapmaster_c_127Historic F5 AccountYou also would get generally better performance (at the cost of missing an EHLO if it's not the 1st command from the client) by doing this:
rule FixUP-SMTP { when SERVER_CONNECTED { peer { TCP::collect 4 } } when CLIENT_DATA { if { [TCP::payload] starts_with "EHLO" } { TCP::respond "500 5.3.3 Unrecognized command\r\n" TCP::payload replace 0 [TCP::payload length] "" } TCP::release } }
- Josh_Hildebran1
Nimbostratus
rapmaster_c, - rapmaster_c_127Historic F5 AccountYes, I tested it. It's working here.
virtual vmail { destination 172.27.138.7:smtp snat automap ip protocol tcp pool mail rule muppet }
rule muppet { when SERVER_CONNECTED { peer { TCP::collect 4 } } when CLIENT_DATA { if { [TCP::payload] starts_with "EHLO" } { TCP::respond "500 5.3.3 Unrecognized command\r\n" TCP::payload replace 0 [TCP::payload length] "" } TCP::release } }
Connected to acheron.pdsea.f5net.com (172.27.138.7). Escape character is '^]'. 220 mail.internal Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Thu, 13 Jul 2006 11:29:26 -0700 EHLO foobar 500 5.3.3 Unrecognized command HELO foobar 250 mail.internal Hello [172.27.138.6] ^]c Connection closed.
- Josh_Hildebran1
Nimbostratus
OMG! If I would use the VIP's IP to test with, it might help! hah.. It works now. - rapmaster_c_127Historic F5 AccountNot that it matters all that much since it's working for your application, but I think the reason it's responding straight away to your "EHLO" command from telnet is because the Microsoft Windows telnet client doesn't enter linemode by default, violating the following section from RFC854 page 4:
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects