Skip to content

Instantly share code, notes, and snippets.

@AlexisHutin
Created May 4, 2025 10:20
Show Gist options
  • Save AlexisHutin/5021eab62eca6c202ce8bcca8d4bc0d9 to your computer and use it in GitHub Desktop.
Save AlexisHutin/5021eab62eca6c202ce8bcca8d4bc0d9 to your computer and use it in GitHub Desktop.
A rollback script of wan2lan.sh (untested for now)
#!/bin/bash
set -e
echo "🧹 Removing custom NetworkManager profile for eth0..."
sudo nmcli connection delete local-eth0 || echo "No connection named 'local-eth0' found."
echo "♻️ Restoring original dnsmasq configuration..."
if [ -f /etc/dnsmasq.conf.backup ]; then
sudo mv /etc/dnsmasq.conf.backup /etc/dnsmasq.conf
else
echo "No dnsmasq.conf.backup found, skipping restore."
fi
echo "🔥 Flushing NAT rules and saving empty rules..."
sudo iptables -t nat -F
sudo iptables-save | sudo tee /etc/iptables/rules.v4 > /dev/null
echo "🌐 Disabling IP forwarding..."
sudo sed -i '/^net.ipv4.ip_forward=1/d' /etc/sysctl.conf
sudo sysctl -p
echo "🔁 Restarting services..."
sudo systemctl restart NetworkManager
sudo systemctl restart dnsmasq
echo "✅ Rollback complete. Your system is restored to its previous state."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment