Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I have a debian box setup as a gateway/firewall using iptables, and a second box to run a web site.
The rules work fine and everything is working.
What I would like to do is to be able to preserve the original ip address of the visitor going to the web server, for log stats, etc. Right now the ip address is always the ip of the gateway/firewall box.
I googled around and it mentions something about using MARK?
Does someone have a howto the can send me to that describes doing this?
It sounds like you're doing SNAT for inbound packets (typically it's only done for outbound ones). Otherwise, the original source IP addresses on the packets should remain. Please post the output of this from the gateway/firewall:
And actually, regardless of what's happening to the incoming traffic, I would think that a "LOG" target as the first action on the incoming traffic at the firewall box, would accurately record the incoming IP. You could further log the masquerade/DNAT/SNAT traffic rules, so you could if you really wanted to, track what IP's traffic went where.
MARK is often used for marking traffic so that something like a shaper can identify it, though probably other reasons too, but I'm not really sure you need MARK for what you're trying to do.
Anyhow, as Win32sux wrote, posting that output may clarify things.
$INET_IFACE is eth0 going the the internet
$INET_IFACE2 is eth1 connecting to the network that has the web server.
This works, but DNAT of course re-writes the incoming ip address from the internet before it is sent to the webserver, so the webserver only sees the ip address assigned to eth1 on the gateway.
Is there another way? The only thing I found so far that is supposed to preserve the ip address as it passes through the firewall is to use the MARK option and a routing table.
This works, but DNAT of course re-writes the incoming ip address from the internet before it is sent to the webserver, so the webserver only sees the ip address assigned to eth1 on the gateway.
DNAT only changes the destination IP. It has nothing to do with the source IP which the server sees. Could you post the requested output please, so that we may see what's going on in your NAT table?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.