iptables assistance?

Kasyx

Expert Member
Joined
Jun 6, 2006
Messages
2,565
Reaction score
1
Location
127.0.0.1
I am trying to set up a firewall rule with iptables to forward all incoming telnet (23) connections to an internal IP (10.146.1.15/32).

Basically:

Code:
EIF="eth0"
IIF="eth1"
iptables -A FORWARD -i $EIF -p tcp -s 0/0 -d 10.146.1.15/32 --dport 23 -j ACCEPT
iptables -A FORWARD -o $EIF -p tcp -d 0/0 --dport 23 -j ACCEPT

This doesn't work.

I know there is something very wrong here, and when someone explains it to me, I will facepalm, but right now I am too sleep-deprived to think straight.

Help!
 
This may seem stupid, but have you enabled ip forwarding?
 
Flash from the past!
Beware .. the gravestone is not quite warm yet.

what i mean is :
echo /proc/sys/net/ipv4/ip_forward

if it's zero, then ip_forwarding is not enabled, but it probably is.
 
Last edited:
Do you want to forward from a public ip to an internal private IP?

if so then you need DNAT

Code:
iptables -I PREROUTING -t nat -s 0/0 -d $myip -p tcp --dport 23 -j DNAT --to-destination $myinternalip

You still need the forward rule aswell though.
 
You'll need those 2 fowarding rules in addition to a prerouting rule as per twiga's post.
 
Top
Sign up to the MyBroadband newsletter
X