Port Forwarding Problem
Without having a look into your scripts, I think you need:
1) Allow INPUT into filter table to the port.
2) Allow FORDWARD into filter table to the redirected conection.
Good luck.
Quoted 17 lines · Julian Labuschagne
Hi everyone I'm a bit new to iptables so please bear with me on this one ;)
I wrote a small firewall that basicaly nats users through my gateway machine only allowing certain hosts on my network Web DNS and Mail access.
This section works fine.
But I also want to port forward any connections from outside to port 800 to a host running inside my LAN.
I added a rule in the PREROUTING table to do this.But it seems that no connection gets forwarded.
If I set my default policies to ACCEPT and add the PREROUTING rule it actualy does the port forwarding correctly.
Quoted 9 lines
I attached a copy of the firewall I wrote with this message.
Please can someone have a look through it for me cause I'm sure I'm just missing something.
Kind Regards Julian.
Samuel D�az Garc�a
Director Gerente
ArcosCom Wireless, S.L.L.
mailto:[email protected]
http://www.arcoscom.com
m�vil: 651 93 72 48
tlfn.: 956 70 13 15 fax: 956 70 34 83
Hi everyone I'm a bit new to iptables so please bear with me on this one ;)
I wrote a small firewall that basicaly nats users through my gateway machine only allowing certain hosts on my network Web DNS and Mail access.
This section works fine.
But I also want to port forward any connections from outside to port 800 to a host running inside my LAN. I added a rule in the PREROUTING table to do this.
But it seems that no connection gets forwarded.
If I set my default policies to ACCEPT and add the PREROUTING rule it actualy does the port forwarding correctly.
I attached a copy of the firewall I wrote with this message.
Please can someone have a look through it for me cause I'm sure I'm just missing something.
Kind Regards Julian.
Quoted 5 lines · Samuel Díaz García
Without having a look into your scripts, I think you need:
1) Allow INPUT into filter table to the port.
2) Allow FORDWARD into filter table to the redirected conection. Good luck.
Line 56: $IPTABLES -A INPUT -i $INET_IFACE -p tcp --dport 800 -j ACCEPT Line 57: $IPTABLES -A INPUT -i $INET_IFACE -p udp --dport 800 -j ACCEPT Line 58:
Line 59: # Forward Chain
Line 60: $IPTABLES -A FORWARD -i $LAN_IFACE -j ACCEPT
Line 61: $IPTABLES -A FORWARD -o $LAN_IFACE -j ACCEPT
Line 85: $IPTABLES -A PREROUTING -t nat -p tcp -d $INET_IP --dport 800 -j DNAT --to 192.168.1.5:800 Line 86: $IPTABLES -A PREROUTING -t nat -p udp -d $INET_IP --dport 800 -j DNAT --to 192.168.1.5:800
This is a few lines from the attached firewall.
I think you may be reffering to these lines of the firewall script.
On Lines 56,57 I allow connections to my gateway on port 800 On Lines 60,61 I allow all connections in the forwarding chain. And on Lines 85,86 is the port forwarding rules.
Kind Regards Julian.
#!/bin/bash
# Set path to iptables binary
IPTABLES=/usr/sbin/iptables
#
# Loopback IP and Interface
#
LO_IFACE="lo"
LO_IP="127.0.0.1"
#
# Internet IP and Interface
#
INET_IP=/sbin/ifconfig ppp0 | grep "inet addr" | cut -d: -f2 | cut -d ' ' -f1 INET_IFACE="ppp0"
#
# LAN Range, IP Address and Interface
#
LAN_IP="192.168.1.1"
LAN_IP_RANGE="192.168.1.0/24"
LAN_BCAST_ADRESS="192.168.1.255"
LAN_IFACE="eth0"
#
# Set default policies
#
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP
#
# Flush Chains
#
$IPTABLES -F
$IPTABLES -t nat -F
#
# Allow loopback interface
#
$IPTABLES -A INPUT -i $LO_IFACE -j ACCEPT
$IPTABLES -A OUTPUT -o $LO_IFACE -j ACCEPT
# Output Chain
$IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --dport 53 -j ACCEPT $IPTABLES -A OUTPUT -o $INET_IFACE -p udp --dport 53 -j ACCEPT $IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --dport 25 -j ACCEPT $IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --dport 80 -j ACCEPT $IPTABLES -A OUTPUT -o $INET_IFACE -p tcp --dport 110 -j ACCEPT
# Input Chain
$IPTABLES -A INPUT -i $INET_IFACE -p tcp -m state --state established,related -j ACCEPT $IPTABLES -A INPUT -i $INET_IFACE -p udp -m state --state established,related -j ACCEPT
$IPTABLES -A INPUT -i $INET_IFACE -p tcp --dport 800 -j ACCEPT $IPTABLES -A INPUT -i $INET_IFACE -p udp --dport 800 -j ACCEPT
# Forward Chain
$IPTABLES -A FORWARD -i $LAN_IFACE -j ACCEPT
$IPTABLES -A FORWARD -o $LAN_IFACE -j ACCEPT
#
# Allow ICMP
#
$IPTABLES -A OUTPUT -o $INET_IFACE -p icmp -j ACCEPT $IPTABLES -A INPUT -i $INET_IFACE -p icmp -j ACCEPT
#
# Users allowed internet access
#
$IPTABLES -A INPUT -i $LAN_IFACE -s 192.168.1.143 -j ACCEPT $IPTABLES -A OUTPUT -o $LAN_IFACE -d 192.168.1.143 -j ACCEPT
$IPTABLES -A INPUT -i $LAN_IFACE -s 192.168.1.5 -j ACCEPT $IPTABLES -A OUTPUT -o $LAN_IFACE -d 192.168.1.5 -j ACCEPT
$IPTABLES -A INPUT -i $LAN_IFACE -s 192.168.1.8 -j ACCEPT $IPTABLES -A OUTPUT -o $LAN_IFACE -d 192.168.1.8 -j ACCEPT
#
# Add port forwarding rule
#
$IPTABLES -A PREROUTING -t nat -p tcp -d $INET_IP --dport 800 -j DNAT --to 192.168.1.5:800 $IPTABLES -A PREROUTING -t nat -p udp -d $INET_IP --dport 800 -j DNAT --to 192.168.1.5:800
#
# Masquerade LAN users (Internet Sharing)
#
$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_IP
I do not recall seeing the original post so I did not see your firewall rule set. If you have your default policy for the FORWARD chain set to DROP you will need to explicitly allow the traffic that you are trying to port forward in your FORWARD table. For example you will need something like this:
iptables -t filter -A FORWARD -i $INet -o $LAN -p tcp --dport 800 -d $IP_of_server_to_forward_to -j ACCEPT iptables -t filter -A FORWARD -i $INet -o $LAN -p udp --dport 800 -d $IP_of_server_to_forward_to -j ACCEPT iptables -t filter -A FORWARD -i $LAN -o $INet -p tcp --dport 800 -s $IP_of_server_to_forward_to -j ACCEPT iptables -t filter -A FORWARD -i $LAN -o $INet -p udp --dport 800 -s $IP_of_server_to_forward_to -j ACCEPT
I added rules for both TCP and UDP as I did not know which protocol you are running. If you don't need one or the other just take the pair (in and out) of rules out.
Grant. . . .
Quoted 32 lines · Samuel Díaz García
Without having a look into your scripts, I think you need:
1) Allow INPUT into filter table to the port.
2) Allow FORDWARD into filter table to the redirected conection. Good luck.Quoted 12 lines · Julian Labuschagne
Hi everyone I'm a bit new to iptables so please bear with me on this one ;)
I wrote a small firewall that basicaly nats users through my gateway machine only allowing certain hosts on my network Web DNS and Mail access. This section works fine.
But I also want to port forward any connections from outside to port 800 to a host running inside my LAN.
I added a rule in the PREROUTING table to do this.
But it seems that no connection gets forwarded.
If I set my default policies to ACCEPT and add the PREROUTING rule it actualy does the port forwarding correctly.
I attached a copy of the firewall I wrote with this message.
Please can someone have a look through it for me cause I'm sure I'm just missing something.
Kind Regards Julian.Samuel D�az Garc�a
Director Gerente
ArcosCom Wireless, S.L.L.
mailto:[email protected]
http://www.arcoscom.com
m�vil: 651 93 72 48tlfn.: 956 70 13 15 fax: 956 70 34 83
Quoted 4 lines · Samuel Díaz García
Without having a look into your scripts, I think you need:
1) Allow INPUT into filter table to the port.
2) Allow FORDWARD into filter table to the redirected conection.
that's not exactly sagely advice. in a port-forwarding situation, all you need is the nat PREROUTING DNAT rule and a filter FORWARD rule. since the destination IP is translated "prerouting" the translated packet will never traverse the filter INPUT chain.
three line guide to "port-forwarding:"
iptables -t nat -A PREROUTING -i $EXT_IF -p tcp --dport 800 \
-j DNAT --to-destination $INSIDE_HOST
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i $EXT_IF -p tcp --syn \
-d $INSIDE_HOST --dport 800 -j ACCEPT-j
--
"Brian: She's a whiney little runt isn't she?
Brian: What? I said runt."
--Family Guy