Difference between revisions of "NAT Tutorial"

From CTWUG Wiki
Jump to: navigation, search
Line 11: Line 11:
 
==Source NAT (SRC-NAT) ==
 
==Source NAT (SRC-NAT) ==
  
[[Image:NAT_ips.jpg]]
+
[[Image:NAT_ips.jpg|frame|left|For Source NAT your PVT IP address will be translated to a Public WUG IP, this so that you pvt ip can communicate with traffic on the public network (Think of it as traffic going out from pvt lan to public lan)]]
  
For Source NAT your PVT IP address will be translated to a Public WUG IP, this so that you pvt ip can communicate with traffic on the public network (Think of it as traffic going out from pvt lan to public lan)
 
  
First configure the IP's for your wlan1 (Wireless Wug interface) and eht1 (Ethernet interface)
 
  
[[Image:Mikrotik_nat_howto01.jpg]]
+
[[Image:Mikrotik_nat_howto01.jpg|frame|left|]]
  
[[Image:Mikrotik_nat_howto02.jpg]]
+
[[Image:Mikrotik_nat_howto02.jpg|frame|left|First configure the IP's for your wlan1 (Wireless Wug interface) and eht1 (Ethernet interface)]]
  
Set your static Wug route of 172.18.0.0/16
 
  
[[Image:Mikrotik_nat_howto03.jpg]]
+
[[Image:Mikrotik_nat_howto03.jpg|frame|left|]]
  
[[Image:Mikrotik_nat_howto04.jpg]]
+
[[Image:Mikrotik_nat_howto04.jpg|frame|left|Set your static Wug route of 172.18.0.0/16]]
  
  
To configure the NAT, go to IP > Firewall and click the NAT tab
 
  
  
 
First we will configure the Source Network Address Translation setting (SRC-NAT). This will translate your local pvt lan ip (10.0.0.3) to a public (wug accessible) ip.
 
First we will configure the Source Network Address Translation setting (SRC-NAT). This will translate your local pvt lan ip (10.0.0.3) to a public (wug accessible) ip.
  
[[Image:Mikrotik_nat_howto05.jpg]]
+
[[Image:Mikrotik_nat_howto05.jpg|frame|left|To configure the NAT, go to IP > Firewall and click the NAT tab]]
  
  
Line 42: Line 38:
  
  
[[Image:Mikrotik_nat_howto06.jpg]]
+
[[Image:Mikrotik_nat_howto06.jpg|frame|left|On the General tab, in the Chain box, we choose srcnat. This will be for all traffic going out via our wlan1 interface, so out interface we make wlan1
 +
Then we go to the Action tab. ]]
  
On the General tab, in the Chain box, we choose srcnat. This will be for all traffic going out via our wlan1 interface, so out interface we make wlan1
 
Then we go to the Action tab.
 
  
 +
[[Image:Mikrotik_nat_howto07.jpg|frame|left|Here we simply choose the masquerade option]]
  
[[Image:Mikrotik_nat_howto07.jpg]]
 
 
Here we simply choose the masquerade option
 
  
  
Line 56: Line 49:
  
  
[[Image:Mikrotik_nat_howto08.jpg]]
+
[[Image:Mikrotik_nat_howto08.jpg|frame|left|Once again, on the General tab, in the Chain box, we choose srcnat. Now instead of just choosing the outgoing interface, we are going to specify the source ip of the packets that need to be translated. So in Src Address we type the ip of our PVT Address to be translated.]]
 
 
Once again, on the General tab, in the Chain box, we choose srcnat. Now instead of just choosing the outgoing interface, we are going to specify the source ip of the packets that need to be translated. So in Src Address we type the ip of our PVT Address to be translated.
 
 
 
  
  
[[Image:Mikrotik_nat_howto09.jpg]]
+
[[Image:Mikrotik_nat_howto09.jpg|frame|left|
 +
Now instead of masquerading all the ips, now in the Action tab, we make action = src-nat. We specify the to-address as the PUBLIC (WUG) ip to be translated to.]]
  
Now instead of masquerading all the ips, now in the Action tab, we make action = src-nat. We specify the to-address as the PUBLIC (WUG) ip to be translated to.
 
  
 
Thats all there is to it !
 
Thats all there is to it !
Line 79: Line 69:
  
  
[[Image:Mikrotik_nat_howto10.jpg]]
+
[[Image:Mikrotik_nat_howto10.jpg|frame|left|]]
  
 
Now in the General Tab, Chain = dstnat. The ip that traffic is destined for is the Public WUG IP, so at dst-address, you need to enter a WUG IP from the range given to you.
 
Now in the General Tab, Chain = dstnat. The ip that traffic is destined for is the Public WUG IP, so at dst-address, you need to enter a WUG IP from the range given to you.
Line 85: Line 75:
  
  
[[Image:Mikrotik_nat_howto11.jpg]]
+
[[Image:Mikrotik_nat_howto11.jpg|frame|left|]]
  
 
Under the Action Tab, we again choose dst-nat, and then the PVT ip that the address should be translated to at to-address.
 
Under the Action Tab, we again choose dst-nat, and then the PVT ip that the address should be translated to at to-address.
Line 93: Line 83:
  
  
[[Image:Mikrotik_nat_howto12.jpg]]
+
[[Image:Mikrotik_nat_howto12.jpg|frame|left|]]
  
 
Same as the previous example, except now we choose the protocol and again we use the dst port.
 
Same as the previous example, except now we choose the protocol and again we use the dst port.
Line 99: Line 89:
  
  
[[Image:Mikrotik_nat_howto13.jpg]]
+
[[Image:Mikrotik_nat_howto13.jpg|frame|left|]]
  
 
Also the To address is our PVT IP and the port on the PVT lan that needs to be forwarded.
 
Also the To address is our PVT IP and the port on the PVT lan that needs to be forwarded.

Revision as of 19:57, 21 September 2009

This is a tutorial to explain how to use your own private lan range for network and NAT network address translation This means, for example, that in your private network you can have whatever private IP you want which is then in turn translated to the public network IP (WUG IP) given to you by your WUG Admin. This tutorial can thus be used by wuggers who dont want to change the internal IP addressing of their LAN.

In tutorial we are using the following ips:

  • Highsite IP: 172.18.100.254
  • Wugger RB IP: 172.18.100.6Wugger Wug Range: 172.18.100.0/29
  • Wugger PVT Lan Range: 10.0.0.0/24
  • Wugger PC PVT IP: 10.0.0.3

Source NAT (SRC-NAT)

For Source NAT your PVT IP address will be translated to a Public WUG IP, this so that you pvt ip can communicate with traffic on the public network (Think of it as traffic going out from pvt lan to public lan)


Mikrotik nat howto01.jpg
First configure the IP's for your wlan1 (Wireless Wug interface) and eht1 (Ethernet interface)


Mikrotik nat howto03.jpg
Set your static Wug route of 172.18.0.0/16



First we will configure the Source Network Address Translation setting (SRC-NAT). This will translate your local pvt lan ip (10.0.0.3) to a public (wug accessible) ip.

To configure the NAT, go to IP > Firewall and click the NAT tab


There are 2 ways in accomplishing this. You can use the masquerade function that will translate ALL ips in your PVT network range to 1 ip (which will be the wug ip of your RB) or you can translate a specific Wug ip from the range give to you, to a specific pvt ip of your lan


  • Option 1 - Using MASQUERADE to hide (translate) all ip's on your pvt lan to 1 public (Wug) IP


On the General tab, in the Chain box, we choose srcnat. This will be for all traffic going out via our wlan1 interface, so out interface we make wlan1 Then we go to the Action tab.


Here we simply choose the masquerade option


  • Option 2 - Translate an IP from your WUG RANGE to an internal PVT IP on your lan range


Once again, on the General tab, in the Chain box, we choose srcnat. Now instead of just choosing the outgoing interface, we are going to specify the source ip of the packets that need to be translated. So in Src Address we type the ip of our PVT Address to be translated.


Now instead of masquerading all the ips, now in the Action tab, we make action = src-nat. We specify the to-address as the PUBLIC (WUG) ip to be translated to.


Thats all there is to it !


Destination NAT (DST-NAT)

For Destination NAT, traffic to a public WUG IP will be forwarded (translated) to your PVT IP address. On some routers this is also known as port forwarding. You can either forward all traffic to a public ip to your ip or you can choose to only forward selected ports to your ip. You can even use 1 public ip and forward different ports to different internal ips. (Like forward port 21 (ftp) to ip 10.0.0.3 and forward port 80 (http) to ip 10.0.0.4.

Once again we go IP > Firewall and choose the NAT Tab

To Forward all ports from the WUG IP 172.18.100.1 to the PVT IP 10.0.0.3


Mikrotik nat howto10.jpg

Now in the General Tab, Chain = dstnat. The ip that traffic is destined for is the Public WUG IP, so at dst-address, you need to enter a WUG IP from the range given to you.


Mikrotik nat howto11.jpg

Under the Action Tab, we again choose dst-nat, and then the PVT ip that the address should be translated to at to-address.

To Forward only port 21 WUG IP 172.18.100.1 to the PVT IP 10.0.0.3 for an FTP server hosted on PVT IP 10.0.0.3


Mikrotik nat howto12.jpg

Same as the previous example, except now we choose the protocol and again we use the dst port.


Mikrotik nat howto13.jpg

Also the To address is our PVT IP and the port on the PVT lan that needs to be forwarded.