Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 04-26-2006, 02:37 PM   #1
LQ Newbie
Registered: Dec 2005
Location: Romania
Distribution: CentOS 6 (2.6.32-279.el6.x86_64)
Posts: 18

Rep: Reputation: 0
Unhappy iptables with port forwarding problem ... please help me

I have a linux router running CentOS 4.2. I want to redirect all trafic coming on eth1 (external interface) to an internal computer (through eth0), say
How can I do that ? I tried many rules, but none worked. Please help me ... I'm confident that this forum has smart guys to answer this question. Below is my firewall and routing script, without any port forwarding rules, because they don't work. I searched the forum, tried that rules, but still not working. please tell me what rule I have to add.
Thanxs in advance.

I A /etc/rc.firewall (sh) Row 1 Col 1 10:12 Ctrl-K H for help
iptables -F

# Trimitem orice ... acceptam numai ce vrem
iptables -P INPUT DROP

# Reguli propriu zise ...

iptables -A INPUT -p tcp -m multiport --dport 21,53,80,110,143,411,443,6238,8008 -j ACCEPT
iptables -A INPUT -p tcp --syn --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --syn --dport 53 -j ACCEPT
iptables -A INPUT -p tcp --syn --dport 80 -j ACCEPT

# Lasam sa mearga orice pe localhost
iptables -A INPUT -m state --state "ESTABLISHED,RELATED" -j ACCEPT

# DoS
iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT

# The thing that actually does NAT !
iptables -t nat -F
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_dynaddr
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ip_nat_irc
iptables -A INPUT -i eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -s -o eth1 -j SNAT --to-source
Old 04-26-2006, 05:51 PM   #2
LQ Newbie
Registered: Dec 2005
Location: Romania
Distribution: CentOS 6 (2.6.32-279.el6.x86_64)
Posts: 18

Original Poster
Rep: Reputation: 0
Can anyone help me please ?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 08:35 PM
iptables problem.....port forwarding..... shahg_shahg Linux - Networking 1 03-22-2006 06:17 AM
IPTables port forwarding problem deadlydemon Linux - Security 2 04-25-2005 05:43 PM
iptables + NAT + Port forwarding problem SirGertrude Linux - Networking 9 05-14-2004 05:02 AM
IPTables Port Forwarding Problem delusi0n Linux - Networking 0 10-02-2001 02:34 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:50 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration