LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-19-2009, 12:03 PM   #1
Fuzzled
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Rep: Reputation: 0
iptables question for network appliance


Greetings,
I'm hoping this is an easy question as I believe I've already fought through the toughest parts already!

Say private lan network of 10.0.0.X, and public network of 68.10.0.1 through 68.10.0.10, with a dual-homed Linux box at 10.0.0.1 (eth0) and 68.10.0.1 (eth1).

I've added devices eth1:2 through eth1:10 as aliases for the remaining public IP's and have several servers on the private lan mapped to these public IP's:
For nat
-A PREROUTING -d 68.10.0.5 -p tcp -m multiport --dports 25,47,80,143,443,444,587,993 -j DNAT --to 10.0.0.20

For filter
-A FORWARD -p tcp -m multiport -d 10.0.0.20 --dports 25,47,80,143,443,444,587,993 -j ACCEPT

This works great and I have all 10 IP's mapping to their respective private LAN servers.

My question is mainly for mail servers since these often require reversed DNS resolution (which are registered under their respective 68.10.0.X addresses)- mapped private servers all appear to source as from 68.10.0.1 source address vs their mapped 68.10.0.X address.

What kind of rule do I need from each server to make them appear to resolve from a different public IP? Is there anything that might break from this as the incoming traffic is filtered only as above?

Any hints, tips or feedback greatly appreciated! Thank you in advance.
 
Old 09-19-2009, 12:30 PM   #2
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
You should configure a POSTROUTING SNAT as well for the 1:1 NAT for the host(s).

example:
Code:
-A POSTROUTING -s 10.0.0.20 -o eth1 -j SNAT --to 68.10.0.5

Last edited by rayfordj; 09-19-2009 at 12:34 PM. Reason: added code example
 
Old 09-19-2009, 01:45 PM   #3
Fuzzled
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you for your speedy reply! The POSTROUTING rule was the missing link.

As this box is also a gateway for LAN users, I already have a topmost rule for
-A POSTROUTING -o eth1 -j MASQUERADE

...so from your example, -A wouldn't work but -I to insert this into the chain seems to do the job:
-I POSTROUTING -s 10.0.0.20 -o eth1 -j SNAT --to 68.10.0.5

Is this a good way to go or is there a preferred method or re-ordering these rules?

Thanks again for the help.
 
Old 09-19-2009, 05:18 PM   #4
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
nah, that should do it. When you run an iptables-save (service iptables save) it will place them with -A rules in the file that is loaded, but they will be in the correct order as is currently running.

That is what I did for one of mine. I had the same -j MASQ for "general" client usage and needed to configure 1:1NAT for an internal host so used the -I to create the rule above the -j MASQ.


 
  


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
how a Linux server is more suited to protect a network vs. a hardware appliance jlarsen Linux - Security 14 07-27-2008 12:45 PM
Network Traffic Monitor Appliance vortmax Linux - Server 2 09-16-2007 09:38 PM
LXer: Network Appliance Targets Linux Clusters LXer Syndicated Linux News 0 07-06-2006 10:21 PM
LXer: Tutorial: Building a Linux Network Appliance, Part 2 LXer Syndicated Linux News 0 06-28-2006 02:54 AM
LXer: Tutorial: Building a Linux Network Appliance, Part 1 LXer Syndicated Linux News 0 06-22-2006 12:03 PM

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

All times are GMT -5. The time now is 06:39 PM.

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