Forum Discussion
Mike_Rausch_628
Nimbostratus
Mar 08, 2007Only allow users from specific Ip address to gain access
I am trying to use a corporate backup tool and they are telling me that I need to open a range of ports on my server from 600-13800 or something like that. I have created a Virtual Server that allows all ports and I created a Pool with one member, which is my server, and it is also allowing all ports. Obviously I do not want to leave everything wide open like this so I was going to write an Irule that would only allow a specific IP to reach the server through this Virtual server. I read a similar post but the person did not seem to get it working. If anyone could help It would be great.
Thanks
Mike
- JRahm
Admin
Try this:when CLIENT_ACCEPTED { if { ! ([IP::client_addr] == "10.10.10.10") } { discard } elseif { ([TCP::local_port] < 300) or ([TCP::local_port] > 13800) } { discard } else { forward } }
- Mike_Rausch_628
Nimbostratus
I meant to write this the first time but the corporate tool will be using a range of IP's like 10.1.1.0 and 10.1.2.0. Can this be put into a data group and the data group get referenced in the Irule - JRahm
Admin
Yes, once you build your datagroup, say allowed_clients,when CLIENT_ACCEPTED { if { not ([matchclass [IP::client_addr] equals [$::allowed_clients]]) } { discard } elseif { ([TCP::local_port] < 300) or ([TCP::local_port] > 13800) } { discard } else { forward } }
- Mike_Rausch_628
Nimbostratus
I tried this rule but I got an error in my logs saying - JRahm
Admin
are the network and mask keywords in your class like this: - Mike_Rausch_628
Nimbostratus
exactly like that. - JRahm
Admin
Sorry, had some extra brackets in there around the class. This may be simpler, and tested fine on my 9.1.2 HF5 system just now.when CLIENT_ACCEPTED { if { ([matchclass [IP::client_addr] equals $::allowed_clients]) and (([TCP::local_port] < 13800) or ([TCP::local_port] > 300))} { log local0. "Connection accepted from [IP::client_addr] destined for tcp port [TCP::local_port]" forward } else { log local0. "Connection discarded from [IP::client_addr] destined for tcp port [TCP::local_port]" discard } }
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