I am fresh to mikrotik configuration and I seem to have some issues with firewall config. My problem is with forwarding ports for internal/lan host.
I have a web server and (l2tp/ipsec, openvpn) vpn server on lan address 10.1.0.4; my WAN ip is let’s say: ex.ter.nal.ip and it’s connected on eth1-WAN port.
The filter rules were already created by default, also I have already tried to set up and move up and down nat rules, with no success.
I am pasting my filter and nat prints. Probably I am missing something obvious, would be happy if someone pointed me where I went wrong…
[admin@MikroTik] /ip firewall filter> print
Flags: X - disabled, I - invalid, D - dynamic
0 D ;;; special dummy rule to show fasttrack counters
chain=forward action=passthrough
1 ;;; defconf: accept ICMP
chain=input action=accept protocol=icmp
2 ;;; defconf: accept established,related
chain=input action=accept connection-state=established,related
3 ;;; defconf: drop all from WAN
chain=input action=drop in-interface=ether1-WAN log=no log-prefix=""
4 ;;; defconf: fasttrack
chain=forward action=fasttrack-connection connection-state=established,related
5 ;;; defconf: accept established,related
chain=forward action=accept connection-state=established,related
6 ;;; defconf: drop invalid
chain=forward action=drop connection-state=invalid log=no log-prefix=""
7 ;;; defconf: drop all from WAN not DSTNATed
chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface=ether1-WAN log=no log-prefix=""
[admin@MikroTik] /ip firewall nat> print
Flags: X - disabled, I - invalid, D - dynamic
0 chain=dstnat action=dst-nat to-addresses=10.1.0.4 to-ports=5001 protocol=tcp dst-address=ex.ter.nal.ip
in-interface=ether1-WAN dst-port=443 log=no log-prefix=""
1 chain=dstnat action=dst-nat to-addresses=10.1.0.4 to-ports=80 protocol=tcp dst-address=ex.ter.nal.ip
in-interface=ether1-WAN dst-port=80 log=no log-prefix=""
2 ;;; defconf: masquerade
chain=srcnat action=masquerade out-interface=ether1-WAN
3 chain=dstnat action=dst-nat to-addresses=10.1.0.4 to-ports=500 protocol=udp dst-address=ex.ter.nal.ip d
log=no log-prefix=""
4 chain=dstnat action=dst-nat to-addresses=10.1.0.4 to-ports=1701 protocol=udp dst-address=ex.ter.nal.ip
log=no log-prefix=""
5 chain=dstnat action=dst-nat to-addresses=10.1.0.4 to-ports=4500 protocol=udp dst-address=ex.ter.nal.ip
log=no log-prefix=""
But that would forward all traffic going at external IP to one internal host, right? Problem is that once I fix this I will have to add more port forwards for different hosts so I guess this doesn’t help me much…
If you have only one external IP address then you must DST-NAT each kind of traffic which means particular ports.
It is similar to telphone switchboard … one external phone number means that you cannot phone someone behind switchboard without dialing extension number. More external phones numbers (IPs) lets you assign them to particular extension numbers (internal hosts)
I think your problem accessing port forwarding services from inside using “public ip” as your point of origin is related to Hairpin NAT. http://wiki.mikrotik.com/wiki/Hairpin_NAT
assuming that
out-interface = bridge ( your local lan, presuming ether2,3..X are in bridge mode )
src-address = network segment of your web server host ( if your web server host has ip 10.1.0.4/255.255.255.0 )