Mikrotik Masquerading Example
Ditulis oleh ch13ry di/pada Juni 1, 2009
As this diagram shows MikroTik router connects two Local Area Networks:
LAN1: 10.0.0.0/24
LAN2: 192.168.0.0/24
Router has two interfaces and three IP addresses. One of these addresses is a global IP address. Interface that is connected to LAN2 has two addresses:
Eth1: 192.168.0.1/24
Eth1: 159.148.172.5/32
Consider the following situation: you want the packets originated from LAN1 to be routed to LAN2 gateway and to masquerade their source addresses, i.e. to replace them by the router’s global IP address.
# Masquerading LAN1 IP addresses
[MikroTik]> ip firewall rule add forward action masq \ srcaddr 10.0.0.0 srcmask 255.255.255.0 interface Eth1
# Routing the packets to LAN2 gateway
[MikroTik]> ip route add gw 192.168.0.254 prefsrc \ 159.148.172.5 interface Eth1