Forum Discussion
Jacob_Becker_41
Nimbostratus
Jun 06, 2006redirect by ip to pool
I'm a newbie to the irules game and I'm just wondering if its possible to redirect traffic from a ip to a pool. Basically what I want to accomplish is redirect all traffic from port 3306 to a pool, but I want to limit who can get to the pool to just our ip.
- Jacob_Becker_41
Nimbostratus
i was hoping something like this would work... - Jacob_Becker_41
Nimbostratus
Actually this would be more like what I would like to do. - hoolio
Cirrostratus
Hello,class my_hosts_networks_class { network 10.0.0.0 mask 255.0.0.0 host 192.168.0.100 } rule filter_clients_rule { when CLIENT_ACCEPTED { if { [matchclass [IP::remote_addr] equals $::my_hosts_networks_class] and [TCP::local_port] == 3306 } { log local0.info "accepted connection from [IP::remote_addr]" pool http_pool } else { log local0.info "rejected connection from [IP::remote_addr]" reject } } }
rule filter_clients_rule { when CLIENT_ACCEPTED { if { [IP::remote_addr] == 192.168.1.1 and [TCP::local_port] == 3306 } { log local0.info "accepted connection from [IP::remote_addr]" pool http_pool } else { log local0.info "rejected connection from [IP::remote_addr]" reject } } }
- Jacob_Becker_41
Nimbostratus
I guess I should add in a bit more. Basically I want to connect to some of our database servers, however they are on a different network. So the idea would be for the load balancer to drop any traffic on that port that didn't orginate from our external ip.rule filter_clients_rule { when CLIENT_ACCEPTED { if { [IP::remote_addr] == $ext_ip and [TCP::local_port] == 3306 } { log local0.info "accepted connection from [IP::remote_addr]" pool mysql } else { log local0.info "rejected connection from [IP::remote_addr]" reject } } }
- hoolio
Cirrostratus
Hello, - Jacob_Becker_41
Nimbostratus
the varible $ext_ip, is not in the code I'm trying to use. I just didn't want to post our ip address on the forum. In that spot I have a actual ip address. - Colin_Walker_12Historic F5 AccountIt sounds like you're adding this to your BIG-IP via the GUI, correct?
when CLIENT_ACCEPTED { if { [IP::remote_addr] == $ext_ip and [TCP::local_port] == 3306 } { log local0.info "accepted connection from [IP::remote_addr]" pool mysql } else { log local0.info "rejected connection from [IP::remote_addr]" reject } }
pieces are only needed if you're adding this directly to the configuration file. The GUI automatically adds those around the code you paste into the text box.rule name { }
- Jacob_Becker_41
Nimbostratus
when using this codewhen CLIENT_ACCEPTED { if { [IP::remote_addr] == $ext_ip and [TCP::local_port] == 3306 } { log local0.info "accepted connection from [IP::remote_addr]" pool mysqlcluster } else { log local0.info "rejected connection from [IP::remote_addr]" reject } }
- Jacob_Becker_41
Nimbostratus
picky is an understatement. Any suggestions on this error? - unRuleY_95363Historic F5 AccountI can't believe no one has mentioned that you should probably be using the IP::addr command to compare IP addresses. Though what you have will work, it will result in an inefficient string comparison.
if { [IP::addr [IP::remote_addr] eq $ext_ip] and ( [TCP::local_port] == 3306 ) } {
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