LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-03-2007, 10:39 AM   #1
technick
LQ Newbie
 
Registered: Sep 2005
Location: Atlanta, Ga
Distribution: Dapper Drake
Posts: 10

Rep: Reputation: 0
Help With Iptables


This is a fairly simple problem I just can't figure out. I need to forward all inbound connections to port 25 (smtp) to another ip address on the same port.

I keep 25 closed on my outbound mail server and some spam filters try to connect back to verify that I am not a bot I guess.

This is what my table looks like right now.

Code:
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp -s 65.131.121.72 -i eth1 --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp -s 65.131.121.75 -i eth1 --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp -s 65.131.121.76 -i eth1 --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 587 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
The system has two interfaces, eth0 (internal) and eth1 (external).

Thanks in advance to anybody that can help me.

Best Regards,

Nick
 
Old 04-03-2007, 10:59 AM   #2
Nathanael
Member
 
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940

Rep: Reputation: 33
"help with iptables" does not really describe the problem...
try to be more specific next time as more people tend to read more descriptive titles :-)

you are looking for the target dnat :-)

iptables -t nat -A -p tcp -i eth1 --dport 25 -j DNAT --to-destination <ipaddr>

search for DNAT in the man pages :-)

Last edited by Nathanael; 04-03-2007 at 11:01 AM.
 
Old 04-03-2007, 01:20 PM   #3
technick
LQ Newbie
 
Registered: Sep 2005
Location: Atlanta, Ga
Distribution: Dapper Drake
Posts: 10

Original Poster
Rep: Reputation: 0
Sorry about the post title, anyways, I tried your suggestion and all I get back is "bad argument 'tcp'".
 
Old 04-03-2007, 01:53 PM   #4
timdsmith
Member
 
Registered: Nov 2003
Location: The Colony, TX
Distribution: Slackware, Debian Etch, FreeBSD, MicroSh*t free.
Posts: 209

Rep: Reputation: 30
You will need two lines to be able to do what you want to do...
Code:
/sbin/iptables -A FORWARD -p tcp -d 192.168.1.100 --dport 25 -j ACCEPT
/sbin/iptables -A PREROUTING -t nat -p tcp -i $EXTIF -d $EXTIP --dport 25 -j DNAT --to 192.168.1.100:25
$EXTIF will be your ethernet card connected to the internet, eth0, eth1, etc...$EXTIP will be your external ip address...If you have a script and want to determine your ip you can get it with this command:
Code:
/sbin/ifconfig eth0 |  /bin/grep 'inet addr' | /usr/bin/awk '{print $2}' | /bin/sed -e 's/.*://'
192.168.1.100 is the ip of the computer you want requests forwarded to.
 
  


Reply



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
An error occured getting IPtables status from the command /etc/rc.d/init.d/iptables s CrazyMAzeY Linux - Newbie 10 08-12-2010 05:25 AM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
Iptables - Couldn't load target `ACCPET':/lib/iptables/libipt_ACCPET.so: z00t Linux - Security 3 01-26-2004 02:24 AM
IPtables Log Analyzer from http://www.gege.org/iptables/ brainlego Linux - Software 0 08-11-2003 06:08 AM
My iptables script is /etc/sysconfig/iptables. How do i make this baby execute on boo ForumKid Linux - General 3 01-22-2002 07:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

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