When testing connectivity in an environment that has IP restrictions, you may want to allow only your own source IP as an exception.
However, the global IP address of your home connection isn’t static; it changes whenever you restart the router or for other reasons.
Updating the allowed IP each time is cumbersome, so I use a Sakura VPS as a jump host.
I could have set up IPsec with something like SoftEther VPN, but since SSH is available, using a SOCKS proxy is easier if everything can be done on the local PC.
Goal
The setup looks like this.
Firefox
↓
localhost:1080
↓
SSH
↓
Sakura VPS
↓
Internet
Creating a SOCKS proxy with SSH
Use SSH’s dynamic port forwarding.
In this case, we’ll configure port 1080.
ssh -D 1080 Bastion
Bastion is the VPS registered under ~/.ssh/config.
Configure it as follows.
Host Bastion
HostName xxx.xxx.xxx.xxx
User username
IdentityFile ~/.ssh/id_ed25519
While the SSH connection is active,
127.0.0.1:1080
becomes the endpoint and listens as a SOCKS proxy.
Verifying that it’s listening
On macOS you can check it with lsof.
lsof -iTCP:1080 -sTCP:LISTEN
For example,
COMMAND PID USER FD TYPE NAME
ssh ... ... ... TCP localhost:socks (LISTEN)
will be displayed.
Verifying that the traffic goes through the VPS with curl
Check with curl before configuring Firefox.
curl --proxy socks5h://127.0.0.1:1080 https://ifconfig.me
If the displayed IP is the Sakura VPS’s global IP, the setup is successful.
Using socks5h also causes hostname resolution to be performed on the SOCKS proxy side.
Routing only Firefox through the SOCKS proxy
In this case we didn’t need to route the entire Mac through the VPS, so we only configure Firefox—the browser used for connectivity testing—to use the proxy.
In fact, having separate browsers for Chrome and Firefox, each with and without IP restrictions, is convenient, which is why we set it up this way.
Open Firefox’s
Settings
↓
General
↓
Network settings
↓
Connection settings
and select “Manual proxy configuration.”
SOCKS Host:
127.0.0.1
Port:
1080
Select the SOCKS version:
SOCKS v5
Also enable
When using SOCKS v5, also use a proxy for DNS
Now only Firefox’s traffic will be routed through the VPS.
Using it for IP‑restriction connectivity testing
For example, if a service restricts connections by source IP like
Allowed IPs:
xxx.xxx.xxx.xxx/32
register the Sakura VPS’s IP address in that list.
Accessing from your home network normally will be denied.
When Firefox is configured to go through the SSH SOCKS proxy,
Firefox
↓
SSH SOCKS
↓
Sakura VPS
↓
IP‑restricted services
the service will see the connection as coming from the VPS’s IP.