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-19-2003, 09:12 PM   #1
Manuel-H
Member
 
Registered: Apr 2003
Location: Singapore
Distribution: Slackware32/64, Ubuntu, Fedora, RHEL
Posts: 138

Rep: Reputation: 15
Incorrect IP displayed.


Hi,

I have this setup to secure my Email server.
However, the incoming IP displayed was not originated from 182.168.0.4. How can I make it to display the original internet incoming address?

Appreciate any suggestions.

My Setup
internet router <--> FW <---> Email Server

Router 2x.x.x.129
FW WAN - 2x.x.x.130
FW LAN- 192.168.0.4
Email Server - 192.168.0.5

At FW I have ip forwading to Email server
iptables -t nat -A PREROUTING -j DNAT -p tcp -d 2x.x.x.141 --dport 25 --to 192.168.0.5:25
iptables -t nat -A PREROUTING -j DNAT -p tcp -d 2x.x.x.141 --dport 110 --to 192.168.0.5:110

My NAT (for the rest of the local LAN PC)
iptables -t nat -P POSTROUTING DROP
iptables -t nat -A POSTROUTING -j MASQUERADE
 
Old 04-20-2003, 09:20 AM   #2
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
not clear for me: what is 2x.x.x.141 address? if you want redirection you should use 2x.x.x.130
are the rules you are using legal (accepted)?
in my opinion it should be:
iptables -t nat -A PREROUTING -d 2x.x.x.130 -p tcp --dport 110 -j DNAT --to-destination=192.168.0.5
iptables -t nat -A PREROUTING -d 2x.x.x.130 -p tcp --dport 25 -j DNAT --to-destination=192.168.0.5

and what abou forwarding?
you should have (for instance) also:
iptables -A FORWARD -m state --state NEW -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -m state --state NEW -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
 
Old 04-20-2003, 11:33 AM   #3
Manuel-H
Member
 
Registered: Apr 2003
Location: Singapore
Distribution: Slackware32/64, Ubuntu, Fedora, RHEL
Posts: 138

Original Poster
Rep: Reputation: 15
not clear for me: what is 2x.x.x.141 address?

Comments: This is my other IP address in the same IP block. (/28 - 16 IPs)

The bottom line.
It doesn't make any differences to have .141 or .130 as the forwarding address. The result is still the same. The packet going thru have the address of the internal IP 192.168.0.4

The three forwarding rules are not needed, without it, it's still working fine. Again the only problem is internal IPs.

I am not sure anyone understand me. I need to capture the actual internet IPs and not my internal IPs (masq). It's for both security and statistics purpose.

TQ.
 
Old 04-20-2003, 02:47 PM   #4
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
"The packet going thru have the address of the internal IP 192.168.0.4" - which packets ? I assume the packets received by email server. It is obvious. You are doing masquerade on both "firewall ends" (i.e. eth cards).
But in fact you need only one-end masquerade:
iptables -t nat -A POSTROUTING -o ethN -j MASQUERADE
where ethN is the eth connected to the router.
BTW: if you have got the static IPs you should use
iptables -t nat -A POSTROUTING -o ethN -j SNAT --to-source=2x.x.x.130
rather than 'MASQUERADE' construction.

Besides, yeah, you're right. I do not understand you. For instance:
"This is my other IP address in the same IP block. (/28 - 16 IPs)" - but is it firewall external eth address? I can only assume that it is. You have nowhere mentioned it.

"It doesn't make any differences to have .141 or .130 as the forwarding address" - ???? If your firewall eth has .130 IP address there is no way (except case of promiscuous mode or multi-IP mode) to see packet send to .141

Regarding "the three forwarding rules". If you really do not need add any forwarding lines it means that the policy for FORWARD chain is ACCEPT.

Last edited by dorian33; 04-20-2003 at 02:49 PM.
 
Old 04-21-2003, 06:39 AM   #5
Manuel-H
Member
 
Registered: Apr 2003
Location: Singapore
Distribution: Slackware32/64, Ubuntu, Fedora, RHEL
Posts: 138

Original Poster
Rep: Reputation: 15
Dear Dorian33,

I think I finally get it. Sorry for the explanation, my first language is not English.

I will try your method and revert it it works.
It may be because of my two ends MASQ, never know this will caused problem.

As for forwarding, yes you are right, I have the default policy as ACCEPT. Will try to get it work and then will work on the block all and accept selected rules.

TQ again.
 
Old 04-21-2003, 11:45 AM   #6
Manuel-H
Member
 
Registered: Apr 2003
Location: Singapore
Distribution: Slackware32/64, Ubuntu, Fedora, RHEL
Posts: 138

Original Poster
Rep: Reputation: 15
The below rules works!
However my default policy cannot be DROP, must be ACCEPT.

iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -A POSTROUTING -o ethN -j SNAT --to-source=2x.x.x.141

Is it a security threat to have the POSTROUTING to default to ACCEPT? similar to the FORWARD default to ACCEPT?

Thanks.
 
Old 04-21-2003, 12:15 PM   #7
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
Nice to hear that it works, although I still don't understand why you use .141 IP address...
Regarding the ACCEPT policy: usually in firewall's setting the policies at least for INPUT and FORWARD chains are set to DROP. And I don't know the situation it could not to be that.
 
Old 04-21-2003, 12:58 PM   #8
Manuel-H
Member
 
Registered: Apr 2003
Location: Singapore
Distribution: Slackware32/64, Ubuntu, Fedora, RHEL
Posts: 138

Original Poster
Rep: Reputation: 15
130 is my firewall, do not want to use that.
Since I have other IP, I choose to use 141, anyway I have 14 usable

My INPUT policy is defaulted to DROP, however, not sure why my POSTROUTING cannot be defaulted to DROP. FORWARD is default to ACCEPT.

My reasoning to use forwarding is to maintain one firewall and harden one machine instead of so many other machines. I only want to open ports 22,25,80,110. The rest if I have forgotten to turn it off, I am still safe. My default firewall rules will block all of them. Otherwise, I will have to maintain and harden 14 machines.

Not sure if this is the standard practice.
 
  


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
Getting More Displayed Info Hambone_20003 Linux - General 2 10-26-2005 10:57 AM
Incorrect Mouse, Incorrect Keymap, and Trapped in X Kenji Miyamoto Debian 8 08-24-2005 02:42 PM
2 CPUs displayed as 4 stand Linux - General 1 06-01-2004 03:14 AM
Hostname Not Displayed Skipper Linux - Networking 0 05-14-2003 05:45 AM
Not all TTF are getting displayed vasah20 Linux - General 4 01-16-2002 11:48 AM

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

All times are GMT -5. The time now is 05:30 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