Debian IPv4/6 Proxy Script

Job ID: 40117453

Budget: €30 – €250 EUR

I need a self-contained script that runs on a fresh Debian server and turns it into a lightweight proxy. The behaviour is simple:

• For both IPv4 and IPv6 traffic, any packet arriving on 1-5 custom ports that I will define in a variable should be transparently forwarded to an external static IPv4/IPv6 address I also specify.

• Everything else—whatever protocol, whatever port—must be redirected with an HTTP 302 to a domain I choose.

The script should be idempotent: running it twice must not create duplicate rules. Feel free to rely on iptables/nftables, ip6tables, or a small HAProxy/Nginx layer if that simplifies the redirect logic; just keep the footprint minimal and stick to Debian-stable packages.

Deliverables
1. Bash (or POSIX-sh) script with clear, editable variables for:
– PORT_LIST (array)
– FORWARD_IP4 / FORWARD_IP6
– REDIRECT_DOMAIN
2. A brief README explaining prerequisites, how to run, and how to roll back the rules.
3. One-liner to verify that forwarding and redirection work (curl or iptables-list).

Acceptance
I will spin up a clean Debian VM, run the script, and confirm:
• traffic on each listed port reaches the static address (tested with netcat)
• traffic on any other port returns the 302 Location header pointing to my domain
• rules survive reboot if I enable the supplied systemd service or rc.local snippet.