Networking Forums

Networking Forums > Computer Networking > Linux Networking > portforwarding just hangs

Reply
Thread Tools Display Modes

portforwarding just hangs

 
 
Avi
Guest
Posts: n/a

 
      03-29-2005, 04:50 PM
i currently have a linux machine acting as my router/server, i have
put together a file of commands to run if i ever need to reply the
iptable rules

#flush the tables
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain

# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth0 -j
MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

echo 1 > /proc/sys/net/ipv4/ip_forward

# Allow loopback access. This rule must come before the rules denying
port access!!
iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A OUTPUT -o lo -p all -j ACCEPT

iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 2049 -j DROP
iptables -A INPUT -p udp -s 0/0 -d 0/0 --dport 2049 -j DROP
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 6000:6009 -j DROP
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 7100 -j DROP
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 515 -j DROP
iptables -A INPUT -p udp -s 0/0 -d 0/0 --dport 515 -j DROP
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 111 -j DROP
iptables -A INPUT -p udp -s 0/0 -d 0/0 --dport 111 -j DROP
iptables -A INPUT -p all -s localhost -i eth0 -j DROP

#setup portforwarding
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 222 -j DNAT --to
192.168.0.2:22

everything works except for the portfowarding. im tryin to allow
access via ssh to a machine within the internal network. The problem
is when i connect from outside, it hangs, it does not refuse the
connection, it just hangs there tryin to connect. It seems to work
half-way but not completely, am i missing something?
 
Reply With Quote
 
 
 
 
Horst Knobloch
Guest
Posts: n/a

 
      04-02-2005, 07:30 PM
Avi <(E-Mail Removed)> wrote:


[iptables script]

For fixing iptables problems the output of iptables-save would
be better. What I miss is the default policy of the involved
chains. Check the FORWARD chain in particular. Make sure that
the traffic is allowed in the FORWARD chain in both directions.

I would also completly rewrite the script to deny by default
and just allow certain traffic through. I would also propose
to look into connection tracking and decide whether it would
make your script more straight-forward. See
http://iptables-tutorial.frozentux.n...-tutorial.html
for further information.


> im tryin to allow
> access via ssh to a machine within the internal network. The problem
> is when i connect from outside, it hangs, it does not refuse the
> connection, it just hangs there tryin to connect. It seems to work
> half-way but not completely, am i missing something?


Use tcpdump/ethereal to check how far your traffic travels
or use the iptables LOG action before any DROP rule for
debugging. Inspecting the counters listed via iptables-save
is also sometimes helpful to detect were the packets are
dropped.

HTH

Ciao, Horst
--
»When pings go wrong (It hurts me too)« E.Clapton/E.James/P.Tscharn
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Portforwarding Eddy Linux Networking 2 11-26-2004 07:20 PM
portforwarding for ftp sever behind NAT tony barnwell Linux Networking 1 09-06-2004 10:06 AM
PortForwarding/DMZ Bill Broadband Hardware 2 02-23-2004 10:12 AM
ip-up.d and portforwarding Michael Gäde Linux Networking 0 11-05-2003 12:22 PM
ip-up.d portforwarding Michael Gäde Linux Networking 0 11-05-2003 09:30 AM



1 2 3 4 5 6 7 8 9 10 11