Generally speaking, if you care about returning your HTTP request, IP spoofing is not possible.
http://en.wikipedia.org/wiki/IP_address_spoofing
If you need it for testing, you can run a virtual machine on your local network for each use case "in the UK" and "not in the UK." Assign a local IP address to each virtual machine that does not change.
Launch an HTTP proxy server in each virtual machine and connect your unit test through different proxies depending on the test case.
Add redefinition logic to your geolocation code to review these well-known local IP addresses to be part of their respective test locations. Please note that a proxy server with good behavior will include both the IP address of the proxy server and the source IP address in the request. Make sure that you use the IP address of the proxy server for geolocation for this unit test (typically, you would like to use the source IP address available for geolocation of production).
Please note that everyone who needs to get around this type of control is very easy. It is possible to access an HTTP proxy server in the UK, which intentionally does not forward the original IP address for a very small fee.
Eric J.
source share