mikrotikvoip:mikrotik_voip_script
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
mikrotikvoip:mikrotik_voip_script [2019/04/24 09:38] – créée ghusson | mikrotikvoip:mikrotik_voip_script [2019/04/27 12:27] (Version actuelle) – ghusson | ||
---|---|---|---|
Ligne 8: | Ligne 8: | ||
# - set variables corresponding to your installation | # - set variables corresponding to your installation | ||
# - run the script | # - run the script | ||
- | # - move the lasts two rules fo the firewall filter rules where it | + | # - move the firewall |
# shoud be # | # shoud be # | ||
######################################################################## | ######################################################################## | ||
- | |||
- | |||
- | # Initialise variables | ||
- | :global internalIp; | ||
- | :global internalInterface; | ||
- | :global externalIp; | ||
- | :global externalInterface; | ||
- | :global voipHttpsPort; | ||
- | :global voipHttpPort; | ||
- | :global voipSIPPort; | ||
- | :global voipSIPsPort; | ||
- | :global voipTunnelPort; | ||
- | :global voipMediaPort; | ||
- | :global initialNatRulesPosition; | ||
# Set variables (change them !!!!) | # Set variables (change them !!!!) | ||
- | :set internalIp " | + | :global |
- | :set internalInterface " | + | :global |
- | :set externalIp " | + | :global |
- | :set externalInterface " | + | :global |
- | :set voipHttpsPort 443; | + | :global |
- | :set voipHttpPort 80; | + | :global |
- | :set voipSIPPort 5060; | + | :global |
- | :set voipSIPsPort ($voipSIPPort + 1); | + | :global |
- | :set voipTunnelPort 5090; | + | :global |
- | :set voipMediaPort " | + | :global |
- | :set initialNatRulesPosition 0; | + | :global |
# Clean previously defined rules | # Clean previously defined rules | ||
Ligne 46: | Ligne 32: | ||
/ip firewall service-port disable sip | /ip firewall service-port disable sip | ||
- | # set NAT rules | + | # Set NAT rules (they have to be before any masquerading rule) |
/ip firewall nat add action=dst-nat \ | /ip firewall nat add action=dst-nat \ | ||
chain=dstnat \ | chain=dstnat \ | ||
Ligne 70: | Ligne 56: | ||
place-before=$initialNatRulesPosition \ | place-before=$initialNatRulesPosition \ | ||
comment=" | comment=" | ||
- | |||
/ip firewall nat add action=dst-nat \ | /ip firewall nat add action=dst-nat \ | ||
Ligne 95: | Ligne 80: | ||
place-before=$initialNatRulesPosition \ | place-before=$initialNatRulesPosition \ | ||
comment=" | comment=" | ||
- | |||
# Set firewall filter rules | # Set firewall filter rules | ||
Ligne 117: | Ligne 101: | ||
log-prefix=voip-in \ | log-prefix=voip-in \ | ||
comment=" | comment=" | ||
+ | |||
+ | # Add drop rule for IP that have been added to " | ||
+ | # address list | ||
+ | /ip firewall filter add action=drop \ | ||
+ | chain=forward \ | ||
+ | src-address-list=blacklist-sip \ | ||
+ | comment=" | ||
+ | |||
+ | # Add drop rule for IP that have been added to " | ||
+ | # address list | ||
+ | /ip firewall filter add action=drop \ | ||
+ | chain=forward \ | ||
+ | src-address-list=blacklist-3cxtunnel \ | ||
+ | comment=" | ||
+ | |||
+ | # Add an IP to " | ||
+ | # number (max 10 SIP sessions per IP) and packet rate (max 100 packets | ||
+ | # in 1mn) - adapt it to your field use. | ||
+ | /ip firewall filter add action=add-src-to-address-list \ | ||
+ | chain=forward \ | ||
+ | protocol=udp \ | ||
+ | dst-port=5060 \ | ||
+ | connection-limit=10, | ||
+ | connection-state=invalid, | ||
+ | limit=100/ | ||
+ | address-list=blacklist-sip \ | ||
+ | address-list-timeout=3h \ | ||
+ | log=yes \ | ||
+ | log-prefix=hacker-sip \ | ||
+ | comment=" | ||
+ | |||
+ | # Add an IP to " | ||
+ | # rate (max 4 tunnels per IP) - adapt it to your field use. | ||
+ | /ip firewall filter add action=add-src-to-address-list \ | ||
+ | chain=forward \ | ||
+ | protocol=udp \ | ||
+ | dst-port=5060 \ | ||
+ | connection-limit=4, | ||
+ | connection-state=invalid, | ||
+ | address-list=blacklist-3cxtunnel \ | ||
+ | address-list-timeout=3h \ | ||
+ | log=yes \ | ||
+ | log-prefix=hacker-3cxtnl \ | ||
+ | comment=" | ||
+ | |||
+ | # Reference documentation for connection-limit and limit: | ||
+ | # | ||
+ | # connection-limit: | ||
+ | # up to and including given value. Should be used together with | ||
+ | # | ||
+ | # very resource intensive. | ||
+ | # limit (integer, | ||
+ | # | ||
+ | # match until this limit is reached. Parameters are written in | ||
+ | # | ||
+ | # * count: packet or bit count per time interval to match | ||
+ | # * time: specifies the time interval in which the packet or bit count | ||
+ | # | ||
+ | # * burst: initial number of packets or bits to match: this number | ||
+ | # gets recharged every 10ms so burst should be at least 1/100 | ||
+ | # of rate per second | ||
+ | # * mode: packet or bit mode | ||
# Clean variables | # Clean variables |
mikrotikvoip/mikrotik_voip_script.1556098718.txt.gz · Dernière modification : 2019/04/24 09:38 de ghusson