Madhu2ram
Feb 26, 2024Nimbostratus
modifying DNS question to add client ip to the DNS:: edns0 options
I have a requirement to modify the incoming DNS request to show client IP address in ENDS option 65523. This is in addition to EDNS Client Subnet option, which we already have enabled through DNS profiles.
I am trying achieve to that through below irule but I see some argument and syntax errors. could someone help me fix this irule.
when DNS_REQUEST {
if { [DNS::edns0 exists] } {
# Get the client's IP address
set client_ip [IP::client_addr]
# Convert client IP to hexadecimal
set hex_client_ip [format "%02x%02x%02x%02x" [lindex [split $client_ip .] 0] [lindex [split $client_ip .] 1] [lindex [split $client_ip .] 2] [lindex [split $client_ip .] 3]]
# Create a DNS EDNS option with the client's IP in hexadecimal as the value
DNS::edns option 65523 $hex_client_ip
}
}