Forum Discussion
msmith_64485
Nimbostratus
Jan 25, 2010IP to FQDN
Looking for an irule that will replace the IP address of outgoing traffic with the FQDN. Issue is external server does not have a valid PTR record to allow resolution. Owner of this server does not want to add PTR and communication with this server is required. If there is a better way to address this issue please direct me to it.
30 Replies
- hoolio
Cirrostratus
I was assuming originally that you were using a network VIP and only wanted to rewrite the host header when certain host header values were seen. If you want to rewrite the host header on all requests, you can remove the check for an IP of 1.1.1.1 (or 2.2.2.2) in the host header value.
If for some reason you do want to check that the host header value is a specific IP address before rewriting the host header, you could continue to use the if {not ([catch... line. But you'd want to check for the VIP address, not the actual server address. This is because clients who use an IP address in the host header will be making a request to the VIP address (2.2.2.2)--not the pool member IP (1.1.1.1).
Aaron - msmith_64485
Nimbostratus
Aaron,
Yes I need to change the request on specific traffic from ip to fqdn. The change needs to be on the traffic that is going to the pool node. So request is made from internal server to ltm, ltm sends traffic to pool node which is a server that is at a third party site. Currently traffic is trying to go out using ip address and communication fails I need to change this ip address to the fqdn so the communication can complete. I made the change you recommended and am still logging just ip addresses and connectio is still failing.
Mike - msmith_64485
Nimbostratus
Aaron,
Yea looks simular execpt When using ip the page can not be found when using fqdn it connects. The connection issue is between the ltm and pool member, not between requesting server and ltm.
Jan 29 09:09:18 tmm tmm[1616]: Rule Test_Log : 192.168.1.205:2112: GET request to 2.2.2.2:1234/example.svc?wsdl
Jan 29 09:09:18 tmm tmm[1616]: Rule Test_Log : 192.168.1.205:2112: Connected to 1.1.1.1:443
Jan 29 09:09:23 tmm tmm[1616]: Rule Test_Log : 192.168.1.205:2113: GET request to 2.2.2.2:1234/example.svc?wsdl
Jan 29 09:09:23 tmm tmm[1616]: Rule Test_Log : 192.168.1.205:2113: Connected to 1.1.1.1:443
Jan 29 09:09:26 tmm tmm[1616]: Rule Test_Log : 192.168.1.205:2114: GET request to 2.2.2.2:1234/example.svc?wsdl
Jan 29 09:09:26 tmm tmm[1616]: Rule Test_Log : 192.168.1.205:2114: Connected to 1.1.1.1:443
2.2.2.2 is ltm vip
1.1.1.1 is pool node member (where traffic needs to go)
1.1.1.1 needs to be server1.example.com as it leaves the ltm to the remote server
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]"
Check if Host header matches 2.2.2.2
Use catch to handle non-IP Host values.
If IP::addr matches 2.2.2.2, $result will be 1
if {not ([catch {IP::addr [HTTP::host] equals 2.2.2.2} result]) && $result==1}{
log local0. "[IP::client_addr]:[TCP::client_port]: Matched IP check for 2.2.2.2 Replacing host header"
HTTP::header replace Host "server1.example.com"
}
}
when SERVER_CONNECTED {
log local0. "[IP::client_addr]:[TCP::client_port]: Connected to [IP::server_addr]:[TCP::server_port]"
}
This is the current rule based on your last recommended configuration - hoolio
Cirrostratus
For some reason, the check of the Host header isn't matching and the host header isn't being replaced. However, I think replacing the host header on every request makes more sense for the scenario. Can you try testing this iRule:when HTTP_REQUEST { Replace the host header with www.example.com HTTP::header replace Host "www.example.com" }
Thanks,
Aaron - msmith_64485
Nimbostratus
Aaron,
If I make this change the irule will only impact the vip that is configured to use the rule correct? - msmith_64485
Nimbostratus
Aaron,
I made the change and am still getting the same results. Does the log need to be changed to return the host value instead of the ip? - hoolio
Cirrostratus
Posted By msmith on 01/29/2010 7:01 AM
Aaron,
If I make this change the irule will only impact the vip that is configured to use the rule correct?
That's correct--an iRule only affects the VIP(s) it's added to.
So you've made the change but the requests still fail?
You can use this rule to log the change:when HTTP_REQUEST { Replace the host header with www.example.com HTTP::header replace Host "www.example.com" } when HTTP_REQUEST priority 501 { Log the host header value log local0. "[IP::client_addr]:[TCP::client_port]: Current HTTP Host: [HTTP::host]" }
Aaron - msmith_64485
Nimbostratus
Aaron,
OK so it looks like it is changing the value
Jan 29 11:50:52 tmm tmm[1616]: Rule Test2 : 192.168.1.205:3700: Current HTTP Host: server1.example.com:3700
Jan 29 11:50:54 tmm tmm[1616]: Rule Test2 : 192.168.1.205:3701: Current HTTP Host: server1.example.com:3701
but I still get the page can not be displayed - msmith_64485
Nimbostratus
What is your address? - hoolio
Cirrostratus
aaron dot hooley at integralis dot com . @ .
Aaron
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
