Hello,
It looks like you had an extra 'if' next to an else that wasn't needed. Please try this (I've not had chance to test it as I'm traveling and writing this from my phone)
when DNS_REQUEST {
if {([IP::addr [IP::client_addr]/24 equals 192.168.163.0]) || ([IP::addr [IP::client_addr]/24 equals 192.168.165.0])} {
if {[LB::status vs 192.168.163.39 ] eq "up" } {
host 192.168.163.39
} elseif {[LB::status vs 192.168.204.45] eq "up" } {
host 192.168.204.45
} elseif {[LB::status vs 192.168.163.39 ] eq "up" } {
host 192.168.163.39
} else {
host 192.168.204.45
}
}
}