45 lines
1.8 KiB
Bash
45 lines
1.8 KiB
Bash
# =============================================================================
|
|
# easyIpTables.sh
|
|
#
|
|
# Allows you to easily set IpTables mappings for incoming and outgoing ports.
|
|
#
|
|
# Copyright (c) 2025 VELENDEU, eetnaviation
|
|
#
|
|
# https://velend.eu/
|
|
# https://git.velend.eu/eetnaviation/shscripts
|
|
#
|
|
# All rights reserved unless otherwise stated.
|
|
#
|
|
# Permission is hereby denied to copy, modify, distribute, sublicense,
|
|
# or sell copies of this software without explicit prior written consent.
|
|
#
|
|
# All dependency trademarks and names if included are subject to copyright
|
|
# of their respective owners.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
# THE SOFTWARE.
|
|
# =============================================================================
|
|
|
|
#!/bin/bash
|
|
|
|
while true; do
|
|
echo "easyIpTables.sh // (c) Copyright 2025 VELENDEU , eetnaviation // See source for more info."
|
|
echo "Press CTRL+C (^C) to quit."
|
|
read -p "Enter outside port: " outsidePort
|
|
read -p "Enter inside port: " insidePort
|
|
|
|
if [[ "$outsidePort" =~ ^[0-9]+$ && "$insidePort" =~ ^[0-9]+$ ]]; then
|
|
iptables -t nat -A PREROUTING -p tcp --dport "$outsidePort" -j REDIRECT --to-port "$insidePort"
|
|
echo "Redirected TCP $outsidePort -> $insidePort, Here are your current IpTables mappings:"
|
|
# Display all mappings
|
|
iptables -t nat -L -v -n
|
|
else
|
|
echo "Invalid input, must be numeric ports."
|
|
fi
|
|
done
|