RWF MikroTik Firewall 4.0 MY Free Version
RWF MikroTik Firewall 4.0 MY Free Version
RWF MikroTik Firewall 4.0 MY Free Version
#########################
# Rick Frey's Basic MikroTik Firewall Rev 4.0 (Free Version)
#
################################################################################
#########################
# Author: Rick Frey
#
# email: support@rickfreyconsulting.com
#
# Username in MikroTik Forum is rickfrey
#
################################################################################
#########################
#
License
#
# This script has been created for use by the general public and may be used fre
ely. This script may
#
# not be sold!
#
################################################################################
#########################
################################################################################
#########################
# Features
#
# -Detect and block brute force attacks to the routers via SSH, Telnet, and Winb
ox (Disables WWW & FTP) #
# -Basic Antivirus filtering
#
# -P2P Blocking
#
# -High Connection Rate detection
#
# -Basic Spam detection
#
# -Basic Port Scanner Detection
#
# -Bogon Address Blocking
#
################################################################################
#########################
################################################################################
###########################################
################################################################################
###########################################
#### Firewall Settings
####
################################################################################
###########################################
/ip firewall connection tracking
################################################################################
###########################################
#### Drop Invalid Connections
####
################################################################################
###########################################
/ip firewall filter
add chain=SectionBreak comment="################################################
###########################################################################
#### Drop Invalid Connections
####
################################################################################
###########################################" disabled=yes
add action=drop chain=input comment="Drop Invalid Connections" connection-state=
invalid disabled=no
add action=drop chain=forward comment="Drop Invalid Connections" connection-stat
e=invalid disabled=no
add chain=SectionBreak comment="Section-Break" disabled=yes
################################################################################
###########################################
#### Must Add Admin IP Addresses in the Address List for Administering the Netwo
rk#########################################
#### BE SURE TO INCLUDE ALL LAN SUBNETS!!!!#####################################
###########################################
################################################################################
###########################################
add chain=SectionBreak comment="################################################
###########################################################################
#### Must Add Admin IP Addresses in the Address List for Administering the Netwo
rk#########################################
#### BE SURE TO INCLUDE ALL LAN SUBNETS!!!!#####################################
###########################################
################################################################################
###########################################" disabled=yes
add action=accept chain=input comment="Accept Exempt IP Addresses" disabled=no s
rc-address-list="Exempt Addresses"
add action=accept chain=forward comment="Accept Exempt IP Addresses" disabled=no
src-address-list="Exempt Addresses"
add chain=SectionBreak comment="Section-Break" disabled=yes
################################################################################
############################################
#### Multiple "Black Lists" have been created to help identify why any given per
son has been blocked.#######################
#### By default Port Scanners Black List is disabled. The Firewall will continue
to add these people to the ################
#### the Black List, but will not block them unless the Black List is enabled. U
se with caution!!!! ########################
#### Once someone is on a Black List they are permanently recorded there. To rem
ove them, go to the address list.###########
################################################################################
############################################
add chain=SectionBreak comment="################################################
############################################################################
#### Multiple "Black Lists" have been created to help identify why any given per
son has been blocked.#######################
#### By default Port Scanners Black List is disabled. The Firewall will continue
to add these people to the ################
#### the Black List, but will not block them unless the Black List is enabled. U
se with caution!!!! ########################
#### Once someone is on a Black List they are permanently recorded there. To rem
ove them, go to the address list.###########
################################################################################
############################################" disabled=yes
add action=drop chain=input comment="Drop anyone in the Black List (Manually Add
ed)" disabled=no src-address-list="Black List"
add action=drop chain=forward comment="Drop anyone in the Black List (Manually A
dded)" disabled=no src-address-list="Black List"
add action=drop chain=input comment="Drop anyone in the Black List (SSH)" disabl
ed=no src-address-list="Black List (SSH)"
add action=drop chain=forward comment="Drop anyone in the Black List (SSH)" disa
bled=no src-address-list="Black List (SSH)"
add action=drop chain=input comment="Drop anyone in the Black List (Telnet)" dis
abled=no src-address-list="Black List (Telnet)"
add action=drop chain=forward comment="Drop anyone in the Black List (Telnet)" d
isabled=no src-address-list="Black List (Telnet)"
add action=drop chain=input comment="Drop anyone in the Black List (Winbox)" dis
abled=no src-address-list="Black List (Winbox)"
add action=drop chain=forward comment="Drop anyone in the Black List (Winbox)" d
isabled=no src-address-list="Black List (Winbox)"
add action=drop chain=input comment="Drop anyone in the Port Scanner List" disab
led=yes src-address-list="WAN Port Scanners"
add action=drop chain=forward comment="Drop anyone in the Port Scanner List" dis
abled=yes src-address-list="WAN Port Scanners"
add action=drop chain=input comment="Drop anyone in the Port Scanner List" disab
led=yes src-address-list="LAN Port Scanners"
add action=drop chain=forward comment="Drop anyone in the Port Scanner List" dis
abled=yes src-address-list="LAN Port Scanners"
add action=drop chain=forward comment="Drop anyone in the Black List (High Conne
ctions)" disabled=yes src-address-list="(High Connection Rates)"
add action=drop chain=input comment="Drop all Bogons" disabled=yes src-address-l
ist=Bogons
add action=drop chain=forward comment="Drop all Bogons" disabled=yes src-address
-list=Bogons
add action=drop chain=forward comment="Drop all P2P" disabled=yes p2p=all-p2p
add chain=output comment="Section Break" disabled=yes
add chain=SectionBreak comment="Section-Break" disabled=yes
################################################################################
###########################################
#### Detect & Block Brute Force Login Attempts
####
################################################################################
###########################################
add chain=SectionBreak comment="################################################
###########################################################################
#### Detect & Block Brute Force Login Attempts
####
################################################################################
###########################################" disabled=yes
add action=jump chain=input comment="Jump to RWF SSH Chain" disabled=no jump-tar
get="RWF SSH Chain"
add action=add-src-to-address-list address-list="Black List (SSH)" address-listtimeout=0s chain="RWF SSH Chain" comment="Transfer repeated attempts from SSH St
age 3 to Black-List" connection-state=new disabled=no dst-port=22 protocol=tcp s
rc-address-list="SSH Stage 3"
add action=add-src-to-address-list address-list="SSH Stage 3" address-list-timeo
ut=1m chain="RWF SSH Chain" comment="Add succesive attempts to SSH Stage 3" conn
ection-state=new disabled=no dst-port=22 protocol=tcp src-address-list="SSH Stag
e 2"
add action=add-src-to-address-list address-list="SSH Stage 2" address-list-timeo
ut=1m chain="RWF SSH Chain" comment="Add succesive attempts to SSH Stage 2" conn
ection-state=new disabled=no dst-port=22 protocol=tcp src-address-list="SSH Stag
e 1"
add action=add-src-to-address-list address-list="SSH Stage 1" address-list-timeo
ut=1m chain="RWF SSH Chain" comment="Add intial attempt to SSH Stage 1 List" con
nection-state=new disabled=no dst-port=22 protocol=tcp
add action=log chain="RWF SSH Chain" comment="Log Black Listed IPs" disabled=no
log-prefix="SSH Black List - " src-address-list="Black List (SSH)"
add action=return chain="RWF SSH Chain" comment="Return From RWF SSH Chain" disa
bled=no
add chain=output comment="Section Break" disabled=yes
add chain=SectionBreak comment="Section-Break" disabled=yes
add chain=SectionBreak comment="Section-Break" disabled=yes
add action=jump chain=input comment="Jump to RWF Telnet Chain" disabled=no jumptarget="RWF Telnet Chain"
add action=add-src-to-address-list address-list="Black List (Telnet)" address-li
st-timeout=0s chain="RWF Telnet Chain" comment="Transfer repeated attempts from
Telnet Stage 3 to Black-List" connection-state=new disabled=no dst-port=23 proto
col=tcp src-address-list="Telnet Stage 3"
add action=add-src-to-address-list address-list="Telnet Stage 3" address-list-ti
meout=1m chain="RWF Telnet Chain" comment="Add succesive attempts to Telnet Stag
e 3" connection-state=new disabled=no dst-port=23 protocol=tcp src-address-list=
"Telnet Stage 2"
add action=add-src-to-address-list address-list="Telnet Stage 2" address-list-ti
meout=1m chain="RWF Telnet Chain" comment="Add succesive attempts to Telnet Stag
e 2" connection-state=new disabled=no dst-port=23 protocol=tcp src-address-list=
"Telnet Stage 1"
add action=add-src-to-address-list address-list="Telnet Stage 1" address-list-ti
meout=1m chain="RWF Telnet Chain" comment="Add Intial attempt to Telnet Stage 1"
connection-state=new disabled=no dst-port=23 protocol=tcp
add action=log chain="RWF Telnet Chain" comment="Log Black Listed IPs" disabled=
no log-prefix="Telnet Black List - " src-address-list="Black List (Telnet)"
add action=return chain="RWF Telnet Chain" comment="Return From RWF Telnet Chain
" disabled=no
add chain=output comment="Section Break" disabled=yes
add chain=SectionBreak comment="Section-Break" disabled=yes
add chain=SectionBreak comment="Section-Break" disabled=yes
add action=jump chain=input comment="Jump to RWF Winbox Chain" disabled=no jumptarget="RWF Winbox Chain"
add action=add-src-to-address-list address-list="Black List (Winbox)" address-li
st-timeout=0s chain="RWF Winbox Chain" comment="Transfer repeated attempts from
Winbox Stage 3 to Black-List" connection-state=new disabled=no dst-port=8291 pro
tocol=tcp src-address-list="Winbox Stage 3"
add action=add-src-to-address-list address-list="Winbox Stage 3" address-list-ti
meout=1m chain="RWF Winbox Chain" comment="Add succesive attempts to Winbox Stag
e 3" connection-state=new disabled=no dst-port=8291 protocol=tcp src-address-lis
t="Winbox Stage 2"
add action=add-src-to-address-list address-list="Winbox Stage 2" address-list-ti
meout=1m chain="RWF Winbox Chain" comment="Add succesive attempts to Winbox Stag
e 2" connection-state=new disabled=no dst-port=8291 protocol=tcp src-address-lis
t="Winbox Stage 1"
add action=add-src-to-address-list address-list="Winbox Stage 1" address-list-ti
meout=1m chain="RWF Winbox Chain" comment="Add Intial attempt to Winbox Stage 1"
connection-state=new disabled=no dst-port=8291 protocol=tcp
add action=log chain="RWF Winbox Chain" comment="Log Black Listed IPs" disabled=
no log-prefix="Winbox Black List - " src-address-list="Black List (Winbox)"
add action=return chain="RWF Winbox Chain" comment="Return From RWF Winbox Chain
" disabled=no
s)"
add action=return chain="RWF Conn Limit Chain (LAN)" comment="Return From High C
onnection Limit Chain"
add action=jump chain=input comment="Jump to High Connection Limiting Chain" jum
p-target="RWF Conn Limit Chain (WAN)"
add action=add-src-to-address-list address-list="(WAN High Connection Rates)" ch
ain="RWF Conn Limit Chain (WAN)" comment="Add WAN High Connections to Address Li
st" connection-limit=100,32 protocol=tcp
add action=log chain="RWF Conn Limit Chain (WAN)" comment="Log Black Listed IPs"
disabled=yes log-prefix="WAN High Conn Limit - " src-address-list="(WAN High Co
nnection Rates)"
add action=return chain="RWF Conn Limit Chain (WAN)" comment="Return From High C
onnection Limit Chain"
add chain=SectionBreak comment="Section-Break" disabled=yes
################################################################################
############################################
#### The Virus Chain has been added at the request of customers, but there is no
guarantee expressed or implied with the ###
#### Virus Chain. ##############################################################
############################################
################################################################################
############################################
add chain=SectionBreak comment="################################################
############################################################################
#### The Virus Chain has been added at the request of customers, but there is no
guarantee expressed or implied with the ###
#### Virus Chain. ##############################################################
############################################
################################################################################
############################################
" disabled=yes
add action=jump chain=input comment="Jump to Virus Chain" disabled=no jump-targe
t=Virus
add action=drop chain=Virus comment="Drop Blaster Worm" disabled=no dst-port=135
-139 protocol=tcp
add action=drop chain=Virus comment="Drop Blaster Worm" disabled=no dst-port=445
protocol=tcp
add action=drop chain=Virus comment="Drop Blaster Worm" disabled=no dst-port=445
protocol=udp
add action=drop chain=Virus comment="Drop Messenger Worm" disabled=no dst-port=1
35-139 protocol=udp
add action=drop chain=Virus comment=Conficker disabled=no dst-port=593 protocol=
tcp
add action=drop chain=Virus comment=Worm disabled=no dst-port=1024-1030 protocol
=tcp
add action=drop chain=Virus comment="ndm requester" disabled=no dst-port=1363 pr
otocol=tcp
add action=drop chain=Virus comment="ndm server" disabled=no dst-port=1364 proto
col=tcp
add action=drop chain=Virus comment="screen cast" disabled=no dst-port=1368 prot
ocol=tcp
add action=drop chain=Virus comment=hromgrafx disabled=no dst-port=1373 protocol
=tcp
add action=drop chain=Virus comment="Drop MyDoom" disabled=no dst-port=1080 prot
ocol=tcp
add action=drop chain=Virus comment=cichlid disabled=no dst-port=1377 protocol=t
cp
################################################################################
###########################################
#### This is the short list that is published on the web at http://www.team-cymr
u.org/Services/Bogons/bogon-bn-nonagg.txt##
#### This list must be maintained or it will cause problems. Check for updates a
t least monthly.###########################
####!!!!! All subnets in this list will be blocked!!! Disable or remove any subn
ets that you are using!!!##################
################################################################################
###########################################
/ip
add
add
add
add
add
add
add
add
add
firewall address-list
list= Bogons address=0.0.0.0/8
list= Bogons address=10.0.0.0/8
list= Bogons address=100.64.0.0/10
list= Bogons address=127.0.0.0/8
list= Bogons address=169.254.0.0/16
list= Bogons address=172.16.0.0/12
list= Bogons address=192.0.0.0/24
list= Bogons address=192.0.2.0/24
list= Bogons address=192.168.0.0/16
disabled=yes
disabled=yes
disabled=yes
disabled=yes
disabled=yes
disabled=yes
disabled=yes
disabled=yes
disabled=yes
add
add
add
add
add
list=
list=
list=
list=
list=
Bogons
Bogons
Bogons
Bogons
Bogons
address=198.18.0.0/15 disabled=yes
address=198.51.100.0/24 disabled=yes
address=203.0.113.0/24 disabled=yes
address=224.0.0.0/4
disabled=yes
address=240.0.0.0/4
disabled=yes
################################################################################
###########################################
#### This is a list of all common ports as found on http://en.wikipedia.org/wiki
/List_of_TCP_and_UDP_port_numbers
##
#### By default they are enabled to prevent immediate problems when applying the
script. Carefully review the list of
##
#### ports and remove or disable entries that are not needed.
##
################################################################################
###########################################
/ip firewall filter
add chain=SectionBreak comment="################################################
###########################################################################
#### This is a list of all common ports as found on http://en.wikipedia.org/wiki
/List_of_TCP_and_UDP_port_numbers
##
#### By default they are enabled to prevent immediate problems when applying the
script. Carefully review the list of
##
#### ports and remove or disable entries that are not needed.
##
################################################################################
###########################################" disabled=yes
add action=jump chain=forward comment="Jump to \"Manage Common Ports\" Chain" ju
mp-target="Manage Common Ports"
add chain="Manage Common Ports" comment="TCP Port Service Multiplexer(TCPMUX)" p
ort=1 protocol=tcp
add chain="Manage Common Ports" comment="TCP Port Service Multiplexer(TCPMUX) "
port=1 protocol=udp
add chain="Manage Common Ports" comment="CompressNETManagement Utility" port=2 p
rotocol=tcp
add chain="Manage Common Ports" comment="CompressNETManagement Utility " port=2
protocol=udp
add chain="Manage Common Ports" comment="CompressNETCompression Process" port=3
protocol=tcp
add chain="Manage Common Ports" comment="CompressNETCompression Process " port=
3 protocol=udp
add chain="Manage Common Ports" comment="Remote Job Entry" port=5 protocol=tcp
add chain="Manage Common Ports" comment="Remote Job Entry " port=5 protocol=udp
add chain="Manage Common Ports" comment="Echo Protocol" port=7 protocol=tcp
add chain="Manage Common Ports" comment="Echo Protocol " port=7 protocol=udp
add chain="Manage Common Ports" comment=Cyberdeck port=8 protocol=tcp
add chain="Manage Common Ports" comment="Cyberdeck " port=8 protocol=udp
add chain="Manage Common Ports" comment="Discard Protocol" port=9 protocol=tcp
add chain="Manage Common Ports" comment="Discard Protocol & Wake-on-LAN " port
=9 protocol=udp
add chain="Manage Common Ports" comment="Active Users (systatservice)" port=11 p
rotocol=tcp
add chain="Manage Common Ports" comment="Active Users (systatservice) " port=11
protocol=udp
add chain="Manage Common Ports" comment="Daytime Protocol(RFC 867)" port=13 prot
ocol=tcp
add chain="Manage Common Ports" comment="Daytime Protocol(RFC 867) " port=13 pr
otocol=udp
tcp
add chain="Manage Common Ports" comment="TorparkControl " port=82 protocol=udp
add chain="Manage Common Ports" comment="Kerberos authentication system" port=88
protocol=tcp
add chain="Manage Common Ports" comment="Kerberos authentication system " port=
88 protocol=udp
add chain="Manage Common Ports" comment="dnsix (DoDNetwork Security for Informat
ion Exchange) Securit Attribute Token Map & PointCast (dotcom)" port=90 protocol
=tcp
add chain="Manage Common Ports" comment="dnsix (DoDNetwork Security for Informat
ion Exchange) Securit Attribute Token Map & PointCast (dotcom) " port=90 proto
col=udp
add chain="Manage Common Ports" comment="WIP Messageprotocol" port=99 protocol=t
cp
add chain="Manage Common Ports" comment="WIP Messageprotocol " port=99 protocol
=udp
add chain="Manage Common Ports" comment="CyberGate RAT protocol " port=100 prot
ocol=udp
add chain="Manage Common Ports" comment="NIChost name" port=101 protocol=tcp
add chain="Manage Common Ports" comment="ISO-TSAP(Transport Service Access Point
)" port=102 protocol=tcp
add chain="Manage Common Ports" comment="ACR/NEMADigital Imaging and Communicati
ons in Medicine(DICOM)" port=104 protocol=tcp
add chain="Manage Common Ports" comment="ACR/NEMADigital Imaging and Communicati
ons in Medicine(DICOM) " port=104 protocol=udp
add chain="Manage Common Ports" comment="CCSO Nameserver Protocol (Qi/Ph)" port=
105 protocol=tcp
add chain="Manage Common Ports" comment="CCSO Nameserver Protocol (Qi/Ph) " por
t=105 protocol=udp
add chain="Manage Common Ports" comment=RemoteTELNETServiceprotocol port=107 pro
tocol=tcp
add chain="Manage Common Ports" comment="SNAGateway Access Server" port=108 prot
ocol=tcp
add chain="Manage Common Ports" comment="SNAGateway Access Server " port=108 pr
otocol=udp
add chain="Manage Common Ports" comment="Post Office Protocolv2 (POP2)" port=109
protocol=tcp
add chain="Manage Common Ports" comment="Post Office Protocolv3 (POP3)" port=110
protocol=tcp
add chain="Manage Common Ports" comment="ONC RPC(SunRPC)" port=111 protocol=tcp
add chain="Manage Common Ports" comment="ONC RPC(SunRPC) " port=111 protocol=ud
p
add chain="Manage Common Ports" comment="IdentAuthentication Service/Identificat
ion Protocol" port=113 protocol=tcp
add chain="Manage Common Ports" comment="Authentication Service(auth) " port=11
3 protocol=udp
add chain="Manage Common Ports" comment="Simple File Transfer Protocol(SFTP)" po
rt=115 protocol=tcp
add chain="Manage Common Ports" comment="SQL(Structured Query Language) Services
" port=118 protocol=tcp
add chain="Manage Common Ports" comment="SQL(Structured Query Language) Services
" port=118 protocol=udp
add chain="Manage Common Ports" comment="Network News Transfer Protocol(NNTP)" p
ort=119 protocol=tcp
add chain="Manage Common Ports" comment="Network Time Protocol(NTP)" port=123 pr
otocol=udp
add chain="Manage Common Ports" comment="FormerlyUnisysUnitary Login, renamed by
Unisys to NXEdit." port=126 protocol=tcp
add chain="Manage Common Ports" comment="FormerlyUnisysUnitary Login, renamed by
Unisys to NXEdit. " port=126 protocol=udp
ion-state=established disabled=yes
add chain=SectionBreak comment="Section-Break" disabled=yes
################################################################################
##########################################
#### Enable this rule in SAFE MODE and test before using########################
##########################################
################################################################################
##########################################
add chain=SectionBreak comment="################################################
##########################################################################
#### Enable this rule in SAFE MODE and test before using########################
##########################################
################################################################################
##########################################" disabled=yes
add action=drop chain=forward comment="Drop all other LAN Traffic" disabled=yes
add action=drop chain=input comment="Drop all other WAN Traffic" disabled=yes
add chain=SectionBreak comment="Section-Break" disabled=yes
/ip
set
set
set
set
set
set
set
service
telnet disabled=no port=23
ftp disabled=yes port=21
www disabled=no port=80
ssh disabled=no port=22
www-ssl certificate=none disabled=yes port=443
api disabled=yes port=8728
winbox disabled=no port=8291
/ip
set
set
set
set
set
set
firewall service-port
ftp disabled=no ports=21
tftp disabled=no ports=69
irc disabled=no ports=6667
h323 disabled=no
sip disabled=no ports=5060,5061
pptp disabled=no