Får inte ett bash skript att fungera :(
#!/bin/bash
EXTERNAL_IP=xxx.xxx.xxx.xxx
INTERNAL_IP=192.168.0.1
INTERNAL_INTERFACE=eth0
EXTERNAL_INTERFACE=eth1
INTERNAL_NETWORK=192.168.0.0/24
# extract the ips and port
NAT_EXT_PORT=$1
NAT_INT_IP=192.168.0.99
NAT_INT_PORT=$1
PROTOCOL=$2
# write the rules!
# this is the prerouting dnat
#iptables -A PREROUTING -t nat -p $PROTOCOL -d $EXTERNAL_IP --dport $NAT_EXT_PORT -j DNAT --to-destination $NAT_INT_IP:$NAT_\
INT_PORT
# This allows packets from external->internal
iptables -A FORWARD -i $EXTERNAL_INTERFACE -o $INTERNAL_INTERFACE -p $PROTOCOL -d $NAT_INT_IP --dport $NAT_INT_PORT -m sta\
te --state NEW,ESTABLISHED,RELATED -j ACCEPT
# This allows packets from internal->external
iptables -A FORWARD -i $INTERNAL_INTERFACE -o $EXTERNAL_INTERFACE -p $PROTOCOL -s $NAT_INT_IP --sport $NAT_INT_PORT -m stat\
e --state NEW,ESTABLISHED,RELATED -j ACCEPT
# This enables access to the 'public' server from the internal network
iptables -t nat -A POSTROUTING -d $NAT_INT_IP -s $INTERNAL_NETWORK -p $PROTOCOL --dport $NAT_INT_PORT -j SNAT --to $INTERNA\
L_IP
echo firewall: dnat: $EXTERNAL_IP:$NAT_EXT_PORT - $NAT_INT_IP:$NAT_INT_PORT
När jag kör det så får jag felmedelandet
[root@celeron portforward]# bash ./portforward.sh 3297 tcp
' specified.2.5: unknown protocol `tcp
Try `iptables -h' or 'iptables --help' for more information.
' (No aliases, :, ! or *).n interface `eth1
' (No aliases, :, ! or *).n interface `eth0
' specified.2.5: unknown protocol `tcp
Try `iptables -h' or 'iptables --help' for more information.
' (No aliases, :, ! or *).n interface `eth0
' (No aliases, :, ! or *).n interface `eth1
' specified.2.5: unknown protocol `tcp
Try `iptables -h' or 'iptables --help' for more information.
' specified.2.5: unknown protocol `tcp
Try `iptables -h' or 'iptables --help' for more information.
:32972.168.0.99 xxx.xxx.xxx.xxx
När jag kör allt manuellt så fungerar det perfekt.
/Viktor