How do i send an ICMP Dest port unreachable on an irule?
I have a ip forwarding virtual server that is supposed to reject packets not in my defined datagroup server_pools destined for a subset of the virtual servers we have. This functionality is working.
Below is the iRule i am using for this
when CLIENT_ACCEPTED {
Is client IP address defined in the server_pools?
if { [class match [IP::client_addr] equals server_pools] }{
forward
log local0. "Request accepted from client: [IP::client_addr] -> [IP::local_addr]"
} else {
reject
log local0. "Request rejected from client: [IP::client_addr] -> [IP::local_addr]"
}
}
However if you traceroute to the vip's they issue a ICMP time exceeded in-transit message. Instead of a ICMP destination port unreachable which lets the traceroute program know it has reached its last hop.
IP 10.0.1.10 > 10.130.65.162: ICMP time exceeded in-transit, length 36
Is there anyway to manually send this message? I know to test for UDP vs TCP i can use the following and change the protocol number.
if {[IP::protocol] == 17 }{
}
Any help would be appreciated.
It appears (on 12.1.1, at least) that the behavior of the
command differs based on whether address translation is enabled. When it is, as I say, an ICMP Port Unreachable message is returned (for UDP traffic). When it is disabled, the behavior you see occurs.reject
There is no way to send a specific, explicit ICMP response from an iRule. However, a "Reject" type server will send an ICMP Port Unreachable in any case. So, you could create a "Reject" virtual server that is bound to no VLAN:
ltm virtual vs-reject { destination 0.0.0.0:any mask any profiles { fastL4 { } } reject source 0.0.0.0/0 translate-address enabled translate-port enabled vlans-enabled vs-index 6 }
Then, in your iRule, instead of using
, forward rejects to this VS:reject
when CLIENT_ACCEPTED { if { ![class match [IP::client_addr] equals server_pools] }{ virtual vs-reject } }
(Notice that the explicit
branch is unnecessary because the VS type is already Forwarding). For me, this produces an identical result for classicforward
(using UDP segments bound for random high-numbered ports), which you appear to be testing here.traceroute