Configure proxy using IP address on macOS
This guide explains how to replace a proxy dns hostname with a direct ip address on macOS, using either the network settings gui or a shell script.
This is useful in environments where:
- Dns resolution is unreliable or slow
- You need to route traffic through a specific egress ip
- Consistent ip usage is required for conditional access or firewall rules
Manual method (system settings)
- Open system settings → network
- Select your current network (e.g., wi-fi or ethernet)
- Click details → proxies
- Under:
- Web proxy (http) and
- Secure web proxy (https)
Replace
proxy.company.comWith the ip address of the proxy (e.g.,192.168.1.10)
- Set the port (usually
8080) - Click ok and apply
Scripted method (bash)
Use this shell script to apply proxy settings using a raw ip address across all network services:
#!/bin/bash
# Define proxy IP and port
PROXY="192.168.1.10"
PORT="8080"
# Get list of all network services (excluding the header)
services=$(networksetup -listallnetworkservices | tail +2)
# Apply proxy settings to each network service
for service in $services; do
echo "Setting IP proxy for: $service"
networksetup -setwebproxy "$service" "$PROXY" "$PORT"
networksetup -setsecurewebproxy "$service" "$PROXY" "$PORT"
networksetup -setproxybypassdomains "$service" $(echo $EXCLUSIONS | tr "," " ")
done