If you have one port for WAN and another for LAN (or logical) it is not too hard to work out a secure solution. Like an onion we will start with a layer and add or remove features as we move through the layers. Note that I prefer to use
interfaces instead of IP addressing because those can be
spoofed.
Option 1: Router and internal network protection
Goals:
. Disallow anything originating from the WAN (ether1).
. Allow anything originating from the LAN (ether2) to setup and receive packets coming back to it.
. Allow ICMP (ping) from the WAN.
Notes:
This is a standard secure setup. However, it does
not allow for internal servers. It also trusts internal clients to be nice and to not be in a hacked state. Suitable for a SOHO network.
ros code
#Router and internal network protection, no internal servers, LAN is friendly
/ip firewall filter
add chain=input action=drop connection-state=invalid comment="Disallow weird packets"
add chain=input action=accept connection-state=new in-interface=LAN comment="Allow LAN access to router and Internet"
add chain=input action=accept connection-state=established comment="Allow connections that originated from LAN"
add chain=input action=accept connection-state=related comment="Allow connections that originated from LAN"
add chain=input action=accept protocol=icmp comment="Allow ping ICMP from anywhere"
add chain=input action=drop comment="Disallow anything from anywhere on any interface"
add chain=forward action=drop connection-state=invalid comment="Disallow weird packets"
add chain=forward action=accept connection-state=new in-interface=LAN comment="Allow LAN access to router and Internet"
add chain=forward action=accept connection-state=established comment="Allow connections that originated from LAN"
add chain=forward action=accept connection-state=related comment="Allow connections that originated from LAN"
add chain=forward action=drop comment="Disallow anything from anywhere on any interface"
Option 2: Allowing for internal servers
Goals:
. Masquerade and allow for internal servers.
Notes:
Uses "Port mapping" technique.
ros code
# Port Forward (map) to an internal LAN server. Note that you'll need to move the
# last line via the GUI to be above DROP rules. If you're using the one above
# place it above the last line: "add chain=forward action=drop"
/ip address add address=1.2.3.4/24 interface=WAN comment="Set public IP of router to a public interface"
/ip firewall nat add chain=srcnat action=masquerade out-interface=WAN comment="Turn on masquerading"
/ip firewall nat add chain=dstnat action=dst-nat protocol=tcp to-address=1.2.3.4 dst-port=80 to-port=80 comment="Create an incoming port map rule"
/ip firewall filter add chain=forward action=accept protocol=tcp dst-port=80 comment="Add a filter exception for port mapped server"
Option 3: Stop bad outgoing traffic
Goals:
. Filter certain connections, ports, and packet types from leaving the LAN to the WAN.
Notes:
When I get time.
Option 4: Stop trusting the internal network
Goals:
. While still allowing for router supplied services (DHCP, DNS, etc.). Disallow anything else.
. Only allow LAN access to the router console from a single trusted client. Disallow all others.
. Segment the LAN clients from each other. They're all crazy anyway.
Notes:
When I get time.