LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Incorrect IP displayed. (https://www.linuxquestions.org/questions/linux-networking-3/incorrect-ip-displayed-55888/)

Manuel-H 04-19-2003 09:12 PM

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

dorian33 04-20-2003 09:20 AM

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

Manuel-H 04-20-2003 11:33 AM

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.

dorian33 04-20-2003 02:47 PM

"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.

Manuel-H 04-21-2003 06:39 AM

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.

Manuel-H 04-21-2003 11:45 AM

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.

dorian33 04-21-2003 12:15 PM

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.

Manuel-H 04-21-2003 12:58 PM

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.


All times are GMT -5. The time now is 08:09 AM.