Operating System - Linux
1825806 Members
2277 Online
109688 Solutions
New Discussion

Re: How implement NAT on debian sarge machine

 
debian111
Regular Advisor

How implement NAT on debian sarge machine

Hi all,
I am tring to make same firewall for my SOHO at home and I have the following situation.

HostA ( two network cards eth0=140.x.x.x and eth1=192.x.x.x) will be a firewall which will NAT
some ports from eth0 to eth1. On eth1 I will connect the rest of my network.
On HostA is installed Debian ant I have administrative rights.

So my question is how translate traffic from eth0 to eth1, I mean from public IP address to private set of address.

If you have some manual for this probelem let me know, I mean send me a link to read it .

Thank you in advance

Debian111
4 REPLIES 4
Sergejs Svitnevs
Honored Contributor

Re: How implement NAT on debian sarge machine

Hi,

There are my examples.

# 1 NAT rule. This rule translates 140.X.X.X:81 {eth0} to 192.X.X.1:80 {eth1}

iptables -t nat -A PREROUTING -d 140.X.X.X \
-i eth0 --protocol tcp --destination-port 81 \
-j DNAT --to-destination 192.X.X.1:80

# 2 NAT rule. This rule translates 140.X.X.X:82 {eth0} to 192.X.X.2:80 {eth1}

iptables -t nat -A PREROUTING -d 140.X.X.X \
-i eth0 --protocol tcp --destination-port 82 \
-j DNAT --to-destination 192.X.X.2:80

Regards
debian111
Regular Advisor

Re: How implement NAT on debian sarge machine

But, should I use iproute command the sintax like
ip route add ///// I read it somewhere, so I am interesting how implement this on my machine.



Regards
Sergejs Svitnevs
Honored Contributor

Re: How implement NAT on debian sarge machine

The iproute package contains advanced IP routing tool, but you need to translate the public (outside public) addresses to private (inside local) addresses in the internal network before packets are forwarded to inside network.
AFAIK, You have to use netfilter/iptables.

Regards
Bill Thorsteinson
Honored Contributor

Re: How implement NAT on debian sarge machine

I would install the shorewall package.

Install the script for a two or three
interface system, and configure NAT as
per the documentation.

Documentation at:
http://www.shorewall.net/shorewall_quickstart_guide.htm