Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,80 @@ chmod +x ip-changer.sh

## Usage

### On Linux
Run the script with root privileges:

```shell
sudo ./ip-changer.sh
```

### On macOS
Run the script (no sudo required):

```shell
./ip-changer.sh
```

#### Requirements for macOS
- [Homebrew](https://brew.sh/) must be installed.
- The script will check for and install Tor and curl via Homebrew if needed.
- Tor is managed using `brew services`.

#### Requirements for Linux
- The script will attempt to install Tor and curl using your system's package manager (apt, yum, pacman, etc.).
- Tor is managed using `systemctl`.

First, enter how long you want to stay on one server before changing the IP.
Then, enter how many times to change the IP. Enter 0 for unlimited changes.

---

## Important Notes & Troubleshooting

### 1. Your Browser or Apps Must Use the Tor Proxy

This script changes your IP for traffic routed through the Tor SOCKS proxy (`127.0.0.1:9050`).
Most browsers and apps do **not** use this proxy by default. To hide your real IP, you must configure your browser or system to use the Tor proxy:

**Firefox:**
- Preferences → General → Network Settings → Settings...
- Select "Manual proxy configuration"
- Set SOCKS Host: `127.0.0.1` Port: `9050`
- Choose SOCKS v5
- Check "Proxy DNS when using SOCKS v5"

**Chrome/Chromium:**
- Start Chrome with:
```
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --proxy-server="socks5://127.0.0.1:9050"
```

**System-wide (macOS):**
- System Preferences → Network → Advanced → Proxies
- Set SOCKS Proxy to `127.0.0.1:9050`

### 2. Disable iCloud Private Relay and VPNs

If you see "Apple iCloud Private Relay" or a VPN in your IP info, your traffic is not using Tor.

- **Disable iCloud Private Relay:**
- System Settings → [Your Name] → iCloud → Private Relay → Turn Off
- **Disable any other VPNs** while using this script.

### 3. IPv6 Leaks

Tor by default only handles IPv4. If your browser uses IPv6, your real IP may leak.
- Disable IPv6 in your network settings, or use browser add-ons to force IPv4.
- Or, configure your browser to use only IPv4 when using the Tor proxy.

### 4. Test Tor Proxy Directly

To verify Tor is working, run:
```bash
curl -s --socks5-hostname 127.0.0.1:9050 https://checkip.amazonaws.com
```
This should show a Tor exit node IP, not your real IP.

---

If you follow these steps, your public IP (as seen by websites) should match a Tor exit node, not your real IP or iCloud Private Relay IP.
95 changes: 75 additions & 20 deletions ip-changer.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

[[ "$UID" -ne 0 ]] && {
echo "Script must be run as root."
[[ "$UID" -ne 0 && "$(uname)" != "Darwin" ]] && {
echo "Script must be run as root (except on macOS)."
exit 1
}

install_packages() {
install_packages_linux() {
local distro
distro=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
distro=${distro//\"/}
Expand All @@ -29,29 +29,74 @@ install_packages() {
esac
}

if ! command -v curl &> /dev/null || ! command -v tor &> /dev/null; then
echo "Installing curl and tor"
install_packages
fi
install_packages_macos() {
if ! command -v brew &> /dev/null; then
echo "Homebrew is not installed. Please install Homebrew from https://brew.sh/ and re-run this script."
exit 1
fi
if ! brew list tor &> /dev/null; then
echo "Installing tor via Homebrew..."
brew install tor
fi
if ! brew list curl &> /dev/null; then
echo "Installing curl via Homebrew..."
brew install curl
fi
}

if ! systemctl --quiet is-active tor.service; then
echo "Starting tor service"
systemctl start tor.service
fi
start_tor_linux() {
if ! systemctl --quiet is-active tor.service; then
echo "Starting tor service"
systemctl start tor.service
fi
}

start_tor_macos() {
if ! pgrep -x "tor" > /dev/null; then
echo "Starting tor service with Homebrew..."
brew services start tor
sleep 3
fi
}

change_ip_linux() {
echo "Reloading tor service"
systemctl reload tor.service
echo -e "\033[34mNew IP address: $(get_ip)\033[0m"
}

change_ip_macos() {
echo "Restarting tor service with Homebrew..."
brew services restart tor
sleep 3
echo -e "\033[34mNew IP address: $(get_ip)\033[0m"
}

get_ip() {
local url get_ip ip
url="https://checkip.amazonaws.com"
get_ip=$(curl -s -x socks5h://127.0.0.1:9050 "$url")
ip=$(echo "$get_ip" | grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
# Use portable grep/awk for IP extraction
ip=$(echo "$get_ip" | grep -Eo '[0-9]{1,3}(\.[0-9]{1,3}){3}')
echo "$ip"
}

change_ip() {
echo "Reloading tor service"
systemctl reload tor.service
echo -e "\033[34mNew IP address: $(get_ip)\033[0m"
}
OS_TYPE=$(uname)
if [ "$OS_TYPE" = "Darwin" ]; then
# macOS
if ! command -v curl &> /dev/null || ! brew list tor &> /dev/null; then
echo "Checking/installing curl and tor for macOS..."
install_packages_macos
fi
start_tor_macos
else
# Linux
if ! command -v curl &> /dev/null || ! command -v tor &> /dev/null; then
echo "Installing curl and tor"
install_packages_linux
fi
start_tor_linux
fi

clear
cat << EOF
Expand All @@ -70,13 +115,23 @@ while true; do
if [ "$interval" -eq "0" ] || [ "$times" -eq "0" ]; then
echo "Starting infinite IP changes"
while true; do
change_ip
interval=$(shuf -i 10-20 -n 1)
if [ "$OS_TYPE" = "Darwin" ]; then
change_ip_macos
# Use bash RANDOM for macOS
interval=$(( ( RANDOM % 11 ) + 10 ))
else
change_ip_linux
interval=$(shuf -i 10-20 -n 1)
fi
sleep "$interval"
done
else
for ((i=0; i< times; i++)); do
change_ip
if [ "$OS_TYPE" = "Darwin" ]; then
change_ip_macos
else
change_ip_linux
fi
sleep "$interval"
done
fi
Expand Down