• Thông báo khẩn - Diễn đàn cần các cộng tác viên vào viết bài viết! Liên Hệ admin.

[Chiasẻ] Command + scripts cho mikrotik

Chia sẻ của bạn với chúng tôi nào

batboyboy

Active member
Nhân viên
Tham gia
29 Tháng bảy 2023
Bài viết
264
Điểm tương tác
49
Điểm
28
Địa chỉ
hanoi
Website
hieu-nguyen.xyz
Credits
1,216
point
10,000
Một số Scripts-MikroTik Tôi lượm lặt và có test một số cái

NO-IP.COM DDNS Update.txt (test X86 ok)


Mã:
# No-IP, Dynamic DNS Updater
# TechBlogClub by Krittin Srithong

#--------------- Change your information here ------------------

:local noipuser "enterNOIPUsername"
:local noippass "enterNOIPPassword"
:local noiphost "enterYOURhostname.ddns.net"
:local inetinterface "pppoe-out1"

#---------------------------------------------------------------

:if ([/interface get $inetinterface value-name=running]) do={
# Get the current IP on the interface
  :local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address]

# Strip the net mask off the IP address
  :for i from=( [:len $currentIP] - 1) to=0 do={
     :if ( [:pick $currentIP $i] = "/") do={
        :set currentIP [:pick $currentIP 0 $i]
     }
  }

# The update URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
  :local url "http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP"
  :local noiphostarray
  :set noiphostarray [:toarray $noiphost]
 
  :foreach host in=$noiphostarray do={
    # Check 1 - resolved IP
    :local resolvedIP [:resolve $host];

    # Check 2 - Saved response from NO-IP
    :local filename ("no-ip_ddns_update-" . $host . ".txt")
    :local savedMatch -1
    :local savedIP "No File";

    if ( [:len [/file find name=$filename]] > 0 ) do={
      :set savedIP [/file get $filename contents]
      :set savedMatch [:find $savedIP $currentIP -1]
    }

    # If either check fails, update IP   
    :if (($currentIP = $resolvedIP) && ($savedMatch >= 0)) do={
      :log info "No-IP: Host $host already on No-IP with IP $resolvedIP"
    } else={
      :log info "No-IP: Sending update for $host - $resolvedIP saved as $savedIP"
      /tool fetch url=($url . "&hostname=$host") user=$noipuser password=$noippass mode=http dst-path=$filename
      :log info "No-IP: Host $host updated on No-IP with IP $currentIP"
    }
  }
} else={
  :log info "No-IP: $inetinterface is not currently running, so therefore will not update."
}

Mikrotik RouterOS Cloudflare Dynamic DNS Script and API Command for List Cloudflare Record ID.txt

Mã:
# Cloudflare Dynamic DNS update script
# Required policy: read, write, test, policy
# Add this script to scheduler
# Install DigiCert root CA or disable check-certificate
# Configuration ---------------------------------------------------------------------

:local TOKEN "__APITOKEN__"
:local ZONEID "__ZONEIDENTIFIER__"
:local RECORDID "__RECORDIDENTIFIER__"
:local RECORDNAME "__DNSRECORD__"
:local WANIF "__WANINTERFACE__"

#------------------------------------------------------------------------------------

:global IP4NEW
:global IP4CUR

:local url "https://api.cloudflare.com/client/v4/zones/$ZONEID/dns_records/$RECORDID/"

:if ([/interface get $WANIF value-name=running]) do={
# Get the current public IP
    :local requestip [tool fetch url="https://ipv4.icanhazip.com" mode=https check-certificate=no output=user as-value]
    :set IP4NEW [:pick ($requestip->"data") 0 ([:len ($requestip->"data")]-1)]
# Check if IP has changed
    :if ($IP4NEW != $IP4CUR) do={
        :log info "CF-DDNS: Public IP changed to $IP4NEW, updating"
        :local cfapi [/tool fetch http-method=put mode=https url=$url check-certificate=no output=user as-value \
            http-header-field="Authorization: Bearer $TOKEN,Content-Type: application/json" \
            http-data="{\"type\":\"A\",\"name\":\"$RECORDNAME\",\"content\":\"$IP4NEW\",\"ttl\":120,\"proxied\":false}"]
        :set IP4CUR $IP4NEW
        :log info "CF-DDNS: Host $RECORDNAME updated with IP $IP4CUR"
    }  else={
        :log info "CF-DDNS: Previous IP $IP4NEW not changed, quitting"
    }
} else={
    :log info "CF-DDNS: $WANIF is not currently running, quitting"
}


* [API Command for List Cloudflare Record ID] *

curl -X GET "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records?name=SUB_DOMAIN" \
     -H "X-Auth-Email: user@example.com" \
     -H "X-Auth-Key: YOUR_API_KEY" \
     -H "Content-Type: application/json"

Port Knocking Security.txt

Mã:
/ip firewall filter
add action=accept chain=input comment="Port Knocking Security" connection-state=established,related
add action=add-src-to-address-list address-list=Temporary address-list-timeout=1m chain=input dst-port=1234 protocol=tcp
add action=add-src-to-address-list address-list=Valid address-list-timeout=1m chain=input dst-port=4321 protocol=tcp src-address-list=Temporary
add action=accept chain=input src-address-list=Valid
add action=drop chain=input

Create [Script-MikroTik] Hairpin NAT.txt


Mã:
#TechBlogClub by Krittin Srithong

/ip firewall address-list
add address=192.168.50.0/24 list=LAN

/ip firewall nat
add action=masquerade chain=srcnat comment="Internel Hairpin NAT" dst-address=!192.168.50.1 src-address-list=LAN
add action=dst-nat chain=dstnat dst-address-type=local dst-port=80 protocol=tcp src-address-list=LAN to-addresses=192.168.50.100 to-ports=80
add action=dst-nat chain=dstnat comment="External Port Forwarding" dst-port=80 in-interface=WAN1 protocol=tcp to-addresses=192.168.50.100 to-ports=80

Dynamic IP problem with manual created routes (DHCP-Client).txt​

Mã:
IP > DHCP Client > Select Interface > Advance Tabs > Script:

################################################################################################
:if ($bound=1) do={
    /ip route add distance=1 gateway=$"gateway-address" routing-mark=via-ISP2 comment="ISP2"
} else={
    /ip route remove [/ip route find comment="ISP2"]
}
################################################################################################



PCC Load Balancing (2 WAN PPPoE) + VLAN + FailOver Netwatch.rsc

Mã:
# jul/22/2023 13:22:28 by RouterOS 7.9.2
# software id =
#
/interface bridge
add name=Bridge-VLAN-TRUNKs
/interface pppoe-client
add disabled=no interface=ether1 name=pppoe-out1 user=ppp1
add disabled=no interface=ether2 name=pppoe-out2 user=ppp2
/interface vlan
add interface=Bridge-VLAN-TRUNKs name=vlan10 vlan-id=10
add interface=Bridge-VLAN-TRUNKs name=vlan20 vlan-id=20
/disk
set slot1 slot=slot1 type=hardware
/interface list
add name=Bridge-LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool0 ranges=192.168.88.2-192.168.88.254
add name=dhcp_pool1 ranges=10.10.10.2-10.10.10.254
add name=dhcp_pool2 ranges=10.20.20.2-10.20.20.254
/ip dhcp-server
add address-pool=dhcp_pool0 interface=Bridge-VLAN-TRUNKs lease-time=1d name=\
    dhcp1
add address-pool=dhcp_pool1 interface=vlan10 lease-time=1d name=dhcp2
add address-pool=dhcp_pool2 interface=vlan20 lease-time=1d name=dhcp3
/port
set 0 name=serial0
/routing table
add disabled=no fib name=via-ISP1
add disabled=no fib name=via-ISP2
/interface bridge port
add bridge=Bridge-VLAN-TRUNKs interface=ether5
/interface list member
add interface=Bridge-VLAN-TRUNKs list=Bridge-LAN
add interface=vlan10 list=Bridge-LAN
add interface=vlan20 list=Bridge-LAN
/ip address
add address=192.168.88.1/24 interface=Bridge-VLAN-TRUNKs network=192.168.88.0
add address=10.10.10.1/24 interface=vlan10 network=10.10.10.0
add address=10.20.20.1/24 interface=vlan20 network=10.20.20.0
/ip dhcp-server network
add address=10.10.10.0/24 dns-server=10.10.10.1 gateway=10.10.10.1
add address=10.20.20.0/24 dns-server=10.20.20.1 gateway=10.20.20.1
add address=192.168.88.0/24 dns-server=192.168.88.1 gateway=192.168.88.1
/ip dns
set allow-remote-requests=yes servers=1.1.1.1,1.0.0.1
/ip firewall address-list
add address=192.168.88.0/24 list=LAN
add address=10.10.10.0/24 list=LAN
add address=10.20.20.0/24 list=LAN
/ip firewall mangle
add action=accept chain=prerouting in-interface=pppoe-out1
add action=accept chain=prerouting in-interface=pppoe-out2
add action=accept chain=prerouting dst-address-list=LAN
add action=mark-connection chain=prerouting in-interface-list=Bridge-LAN \
    new-connection-mark=ISP1_Conn passthrough=yes per-connection-classifier=\
    both-addresses:2/0
add action=mark-routing chain=prerouting connection-mark=ISP1_Conn \
    in-interface-list=Bridge-LAN new-routing-mark=via-ISP1 passthrough=no
add action=mark-connection chain=prerouting in-interface-list=Bridge-LAN \
    new-connection-mark=ISP2_Conn passthrough=yes per-connection-classifier=\
    both-addresses:2/1
add action=mark-routing chain=prerouting connection-mark=ISP2_Conn \
    in-interface-list=Bridge-LAN new-routing-mark=via-ISP2 passthrough=no
add action=mark-connection chain=prerouting in-interface=pppoe-out1 \
    new-connection-mark=ISP1_Conn passthrough=yes
add action=mark-routing chain=output connection-mark=ISP1_Conn \
    new-routing-mark=via-ISP1 passthrough=no
add action=mark-connection chain=prerouting in-interface=pppoe-out2 \
    new-connection-mark=ISP2_Conn passthrough=yes
add action=mark-routing chain=output connection-mark=ISP2_Conn \
    new-routing-mark=via-ISP2 passthrough=no
/ip firewall nat
add action=masquerade chain=srcnat out-interface=pppoe-out1
add action=masquerade chain=srcnat out-interface=pppoe-out2
/ip route
add comment=via-ISP1_To_ISP1 disabled=no distance=1 dst-address=0.0.0.0/0 \
    gateway=pppoe-out1 pref-src="" routing-table=via-ISP1 scope=30 \
    suppress-hw-offload=no target-scope=10
add comment=via-ISP2_To_ISP2 disabled=no distance=1 dst-address=0.0.0.0/0 \
    gateway=pppoe-out2 pref-src="" routing-table=via-ISP2 scope=30 \
    suppress-hw-offload=no target-scope=10
add comment="Redirect via-ISP1 To ISP2" disabled=no distance=2 dst-address=\
    0.0.0.0/0 gateway=pppoe-out2 pref-src="" routing-table=via-ISP1 scope=30 \
    suppress-hw-offload=no target-scope=10
add comment="Redirect via-ISP2 To ISP1" disabled=no distance=2 dst-address=\
    0.0.0.0/0 gateway=pppoe-out1 pref-src="" routing-table=via-ISP2 scope=30 \
    suppress-hw-offload=no target-scope=10
add comment=To-ISP1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    pppoe-out1 pref-src="" routing-table=main scope=30 suppress-hw-offload=no \
    target-scope=10
add comment=To-ISP2 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=\
    pppoe-out2 pref-src="" routing-table=main scope=30 suppress-hw-offload=no \
    target-scope=10
add comment="Netwatch ISP1 (Quad9 DNS)" disabled=no distance=1 dst-address=\
    9.9.9.9/32 gateway=pppoe-out1 pref-src="" routing-table=main scope=30 \
    suppress-hw-offload=no target-scope=10
add comment="Netwatch ISP2 (Google DNS)" disabled=no distance=1 dst-address=\
    8.8.8.8/32 gateway=pppoe-out2 pref-src="" routing-table=main scope=30 \
    suppress-hw-offload=no target-scope=10
/system identity
set name=R1
/system note
set show-at-login=no
/tool netwatch
add comment=ISP1 disabled=no down-script="ip route disable [find comment=To-IS\
    P1]\r\
    \nip route disable [find comment=via-ISP1_To_ISP1]\r\
    \n:log warning \"ISP1 is down\"\r\
    \n/ip firewall connection remove [find]" host=9.9.9.9 http-codes="" \
    interval=10s test-script="" timeout=800ms type=simple up-script="ip route \
    enable [find comment=To-ISP1]\r\
    \nip route enable [find comment=via-ISP1_To_ISP1]\r\
    \n:log warning \"ISP1 is up\""
add comment=ISP2 disabled=no down-script="ip route disable [find comment=To-IS\
    P2]\r\
    \nip route disable [find comment=via-ISP2_To_ISP2]\r\
    \n:log warning \"ISP1 is down\"\r\
    \n/ip firewall connection remove [find]" host=8.8.8.8 http-codes="" \
    interval=10s test-script="" timeout=800ms type=simple up-script="ip route \
    enable [find comment=To-ISP2]\r\
    \nip route enable [find comment=via-ISP2_To_ISP2]\r\
    \n:log warning \"ISP2 is up\""

PCC Load Balancing (2 WAN PPPoE).txt​


Mã:
PCC Load Balancing (2 WAN PPPoE)
ISP1 - Download Speed: 1000 Mbps, Upload Speed: 500 Mbps
ISP2 - Download Speed: 1000 Mbps, Upload Speed: 500 Mbps

VLAN10 (10.10.10.0/24)
VLAN20 (10.20.20.0/24)

# 1. ALL LAN Address Lists
/ip firewall address-list
add address=10.10.10.0/24 list=LAN
add address=10.20.20.0/24 list=LAN

# 2. Create Route tables
  2.1. Routing > Tables
    For via-ISP1,
     - Press "+"
     - Name: via-ISP1
     - FIB: Check
     - Press "OK"
  2.2 Routing > Tables
    For via-ISP1,
     - Press "+"
     - Name: via-ISP1
     - FIB: Check
     - Press "OK"

# 3. Script PCC Load Balancing (2 WAN PPPoE)

/ip firewall mangle
add action=mark-routing chain=prerouting dst-address-list=!LAN new-routing-mark=via-ISP1 passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0 src-address-list=LAN
add action=mark-routing chain=prerouting dst-address-list=!LAN new-routing-mark=via-ISP2 passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1 src-address-list=LAN

OR

/ip firewall mangle
add action=mark-routing chain=prerouting dst-address-type=!local new-routing-mark=via-ISP1 passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0 src-address-list=LAN
add action=mark-routing chain=prerouting dst-address-type=!local new-routing-mark=via-ISP2 passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1 src-address-list=LAN

# 4. Create 2 routes to ISP1 and ISP2 with the mark routing that you have just created
 

batboyboy

Active member
Nhân viên
Tham gia
29 Tháng bảy 2023
Bài viết
264
Điểm tương tác
49
Điểm
28
Địa chỉ
hanoi
Website
hieu-nguyen.xyz
Credits
1,216
point
10,000
Một số Sckip cấm mạng xa hội

Mạng xã hội Tào lao Tiktok

Mã:
/ip firewall filter
add action=drop chain=forward dst-address-list=TikTok src-address=192.168.50.0/24 comment="Blocking TikTok using RouterOS"

/ip firewall mangle
add action=add-dst-to-address-list address-list=TikTok address-list-timeout=4w2d chain=prerouting content=.tiktok.com src-address=192.168.50.0/24 comment="Detecting IP Addresses TikTok"
add action=add-dst-to-address-list address-list=TikTok address-list-timeout=4w2d chain=prerouting content=.tiktokv.com src-address=192.168.50.0/24
add action=add-dst-to-address-list address-list=TikTok address-list-timeout=4w2d chain=prerouting content=.tiktokcdn.com src-address=192.168.50.0/24
add action=add-dst-to-address-list address-list=TikTok address-list-timeout=4w2d chain=prerouting content=.byteoversea.com src-address=192.168.50.0/24
add action=add-dst-to-address-list address-list=TikTok address-list-timeout=4w2d chain=prerouting content=.ibyteimg.com src-address=192.168.50.0/24
add action=add-dst-to-address-list address-list=TikTok address-list-timeout=4w2d chain=prerouting content=.ibytedtos.com src-address=192.168.50.0/24
add action=add-dst-to-address-list address-list=TikTok address-list-timeout=4w2d chain=prerouting content=.myqcloud.com src-address=192.168.50.0/24

Blocking PUBG Mobile traffic using RouterOS.txt

Mã:
/ip firewall filter
add action=drop chain=forward dst-address-list=PUBGM src-address=192.168.50.0/24 comment="Blocking PUBG Mobile traffic using RouterOS"

/ip firewall mangle
add action=add-dst-to-address-list address-list=PUBGM address-list-timeout=4d chain=prerouting dst-port=10012,17500 protocol=tcp comment="Detecting IP Addresses PUBG Mobile"
add action=add-dst-to-address-list address-list=PUBGM address-list-timeout=4d chain=prerouting dst-port=10000-30000 protocol=udp

Blocking Facebook on RouterOS using Address-Lists.txt​




Mã:
/ip firewall filter
add action=drop chain=forward dst-address-list=Facebook src-address=192.168.50.0/24 comment="Blocking Facebook on RouterOS using Address-Lists"

/ip firewall address-list
add address=146.88.59.0/24 list=Facebook
add address=74.119.76.0/22 list=Facebook
add address=45.64.40.0/22 list=Facebook
add address=69.63.176.0/20 list=Facebook
add address=31.13.64.0/18 list=Facebook
add address=66.220.144.0/20 list=Facebook
add address=69.171.224.0/19 list=Facebook
add address=103.4.96.0/22 list=Facebook
add address=173.252.64.0/19 list=Facebook
add address=173.252.96.0/19 list=Facebook
add address=179.60.192.0/22 list=Facebook
add address=204.15.20.0/22 list=Facebook
add address=31.13.24.0/21 list=Facebook
add address=199.201.64.0/22 list=Facebook
add address=185.60.216.0/22 list=Facebook
add address=157.240.0.0/16 list=Facebook
add address=129.205.94.0/23 list=Facebook


Blocking Facebook on RouterOS using TLS Host.txt

Mã:
/ip firewall filter
add action=drop chain=forward dst-address-list=Facebook src-address=192.168.50.0/24 comment="Blocking Facebook on RouterOS using TLS Host"

/ip firewall mangle
add action=add-dst-to-address-list address-list=Facebook address-list-timeout=4w2d chain=prerouting dst-port=443 protocol=tcp tls-host=*.facebook.com comment="Detecting IP Addresses Facebook"


After putting the script on RouterOS. Please do this before using it.
1. Clear Traffic Connections on RouterOS.
   - IP -> Firewall -> Connections
   - Delete All Connections (Shortcut key: CTRL + A And Click remove button)
2. Clear Cache on your web browser.

Blocking LINE on RouterOS using Address-Lists.txt​


Mã:
/ip firewall filter
add action=drop chain=forward dst-address-list=LINE src-address=192.168.50.0/24 comment="Blocking LINE on RouterOS using Address-Lists"

/ip firewall address-list add list=LINE address=203.104.158.0/24
/ip firewall address-list add list=LINE address=203.104.157.0/24
/ip firewall address-list add list=LINE address=203.104.156.0/24
/ip firewall address-list add list=LINE address=203.104.156.0/23
/ip firewall address-list add list=LINE address=203.104.155.0/24
/ip firewall address-list add list=LINE address=203.104.154.0/24
/ip firewall address-list add list=LINE address=203.104.153.0/24
/ip firewall address-list add list=LINE address=203.104.152.0/24
/ip firewall address-list add list=LINE address=203.104.152.0/22
/ip firewall address-list add list=LINE address=203.104.151.0/24
/ip firewall address-list add list=LINE address=203.104.150.0/24
/ip firewall address-list add list=LINE address=203.104.149.0/24
/ip firewall address-list add list=LINE address=203.104.148.0/24
/ip firewall address-list add list=LINE address=203.104.147.0/24
/ip firewall address-list add list=LINE address=203.104.146.0/24
/ip firewall address-list add list=LINE address=203.104.145.0/24
/ip firewall address-list add list=LINE address=203.104.144.0/24
/ip firewall address-list add list=LINE address=203.104.144.0/21
/ip firewall address-list add list=LINE address=203.104.143.0/24
/ip firewall address-list add list=LINE address=203.104.142.0/24
/ip firewall address-list add list=LINE address=203.104.141.0/24
/ip firewall address-list add list=LINE address=203.104.140.0/24
/ip firewall address-list add list=LINE address=203.104.139.0/24
/ip firewall address-list add list=LINE address=203.104.138.0/24
/ip firewall address-list add list=LINE address=203.104.137.0/24
/ip firewall address-list add list=LINE address=203.104.136.0/24
/ip firewall address-list add list=LINE address=203.104.135.0/24
/ip firewall address-list add list=LINE address=203.104.134.0/24
/ip firewall address-list add list=LINE address=203.104.133.0/24
/ip firewall address-list add list=LINE address=203.104.132.0/24
/ip firewall address-list add list=LINE address=203.104.131.0/24
/ip firewall address-list add list=LINE address=203.104.130.0/24
/ip firewall address-list add list=LINE address=203.104.129.0/24
/ip firewall address-list add list=LINE address=203.104.128.0/24
/ip firewall address-list add list=LINE address=203.104.128.0/20
/ip firewall address-list add list=LINE address=147.92.248.0/21
/ip firewall address-list add list=LINE address=147.92.247.0/24
/ip firewall address-list add list=LINE address=147.92.226.0/24
/ip firewall address-list add list=LINE address=147.92.200.0/21
/ip firewall address-list add list=LINE address=147.92.188.0/24
/ip firewall address-list add list=LINE address=147.92.169.0/24
/ip firewall address-list add list=LINE address=147.92.164.0/22
/ip firewall address-list add list=LINE address=147.92.135.0/24
/ip firewall address-list add list=LINE address=147.92.134.0/24
/ip firewall address-list add list=LINE address=147.92.133.0/24
/ip firewall address-list add list=LINE address=147.92.132.0/24
/ip firewall address-list add list=LINE address=147.92.131.0/24
/ip firewall address-list add list=LINE address=147.92.130.0/24
/ip firewall address-list add list=LINE address=147.92.129.0/24
/ip firewall address-list add list=LINE address=147.92.128.0/24
/ip firewall address-list add list=LINE address=147.92.128.0/17
/ip firewall address-list add list=LINE address=119.235.237.0/24
/ip firewall address-list add list=LINE address=119.235.236.0/24
/ip firewall address-list add list=LINE address=119.235.236.0/23
/ip firewall address-list add list=LINE address=119.235.235.0/24
/ip firewall address-list add list=LINE address=119.235.232.0/24
/ip firewall address-list add list=LINE address=119.235.224.0/24
/ip firewall address-list add list=LINE address=103.2.31.0/24
/ip firewall address-list add list=LINE address=103.2.30.0/24
/ip firewall address-list add list=LINE address=103.2.30.0/23
/ip firewall address-list add list=LINE address=103.2.28.0/24


Blocking Netflix traffic using RouterOS.txt

Mã:
/ip firewall filter
add action=drop chain=forward dst-address-list=Netflix src-address=192.168.50.0/24 comment="Blocking Netflix traffic using RouterOS"

/ip firewall mangle
add action=add-dst-to-address-list address-list=Netflix address-list-timeout=4w2d chain=prerouting content=nflxvideo.net src-address=192.168.50.0/24 comment="Detecting IP Addresses Netflix"




Blocking Youtube on RouterOS using TLS Host.txt

Mã:
/ip firewall filter
add action=drop chain=forward comment="Blocking Youtube on RouterOS using TLS Host" dst-address-list=Youtube src-address=192.168.50.0/24

/ip firewall mangle
add action=add-dst-to-address-list address-list=Youtube address-list-timeout=4w2d chain=prerouting comment="Detecting IP Addresses Youtube" protocol=tcp tls-host=*.youtube.com
add action=add-dst-to-address-list address-list=Youtube address-list-timeout=4w2d chain=prerouting protocol=tcp tls-host=*youtube*

Block Bogon IP Addresses on MikroTik Firewal…l.txt
Mã:
/ip firewall address-list
add list="BOGONS" address=0.0.0.0/8
add list="BOGONS" address=10.0.0.0/8
add list="BOGONS" address=100.64.0.0/10
add list="BOGONS" address=127.0.0.0/8
add list="BOGONS" address=169.254.0.0/16
add list="BOGONS" address=172.16.0.0/12
add list="BOGONS" address=192.0.0.0/24
add list="BOGONS" address=192.0.2.0/24
add list="BOGONS" address=192.168.0.0/16
add list="BOGONS" address=198.18.0.0/15
add list="BOGONS" address=198.51.100.0/24
add list="BOGONS" address=203.0.113.0/24
add list="BOGONS" address=224.0.0.0/3

/ip firewall filter
add action=drop chain=forward comment="Block Bogon IP Addresses" in-interface=pppoe-out1 src-address-list=BOGONS

Blocking RoV mobile traffic using RouterOS.txt

Mã:
/ip firewall filter
add action=drop chain=forward dst-address-list=RoV src-address=192.168.50.0/24 comment="Blocking Garena RoV traffic using RouterOS"

/ip firewall mangle
add action=add-dst-to-address-list address-list=RoV address-list-timeout=4d chain=prerouting dst-port=20000 protocol=tcp comment="Detecting IP Addresses Garena RoV (Sv.TH)"

Blocking Steam on RouterOS using Address-Lists.txt

Mã:
/ip firewall filter
add action=drop chain=forward dst-address-list=Steam src-address=192.168.50.0/24 comment="Blocking Steam on RouterOS using Address-Lists"

/ip firewall address-list
add address=45.121.184.0/23 list=Steam
add address=45.121.186.0/23 list=Steam
add address=103.10.124.0/24 list=Steam
add address=103.10.125.0/24 list=Steam
add address=103.28.54.0/23 list=Steam
add address=146.66.152.0/23 list=Steam
add address=146.66.154.0/24 list=Steam
add address=146.66.155.0/24 list=Steam
add address=146.66.156.0/23 list=Steam
add address=146.66.158.0/23 list=Steam
add address=153.254.86.0/24 list=Steam
add address=155.133.224.0/23 list=Steam
add address=155.133.227.0/24 list=Steam
add address=155.133.228.0/23 list=Steam
add address=155.133.230.0/23 list=Steam
add address=155.133.232.0/24 list=Steam
add address=155.133.233.0/24 list=Steam
add address=155.133.234.0/24 list=Steam
add address=155.133.235.0/24 list=Steam
add address=155.133.236.0/23 list=Steam
add address=155.133.238.0/24 list=Steam
add address=155.133.239.0/24 list=Steam
add address=155.133.240.0/23 list=Steam
add address=155.133.242.0/23 list=Steam
add address=155.133.244.0/24 list=Steam
add address=155.133.245.0/24 list=Steam
add address=155.133.246.0/23 list=Steam
add address=155.133.248.0/24 list=Steam
add address=155.133.249.0/24 list=Steam
add address=155.133.250.0/24 list=Steam
add address=155.133.252.0/24 list=Steam
add address=155.133.253.0/24 list=Steam
add address=155.133.254.0/24 list=Steam
add address=155.133.255.0/24 list=Steam
add address=162.254.192.0/24 list=Steam
add address=162.254.193.0/24 list=Steam
add address=162.254.194.0/23 list=Steam
add address=162.254.196.0/24 list=Steam
add address=162.254.197.0/24 list=Steam
add address=162.254.198.0/24 list=Steam
add address=162.254.199.0/24 list=Steam
add address=185.25.180.0/23 list=Steam
add address=185.25.182.0/24 list=Steam
add address=185.25.183.0/24 list=Steam
add address=190.216.121.0/24 list=Steam
add address=190.217.33.0/24 list=Steam
add address=192.69.96.0/23 list=Steam
add address=205.185.194.0/24 list=Steam
add address=205.196.6.0/24 list=Steam
add address=208.64.200.0/24 list=Steam
add address=208.64.201.0/24 list=Steam
add address=208.64.202.0/24 list=Steam
add address=208.64.203.0/24 list=Steam
add address=208.78.164.0/23 list=Steam
add address=208.78.166.0/24 list=Steam
add address=208.78.167.0/24 list=Steam
 
Chỉnh sửa lần cuối:

batboyboy

Active member
Nhân viên
Tham gia
29 Tháng bảy 2023
Bài viết
264
Điểm tương tác
49
Điểm
28
Địa chỉ
hanoi
Website
hieu-nguyen.xyz
Credits
1,216
point
10,000
Drop Port Scan Attacks using MikroTik Firewall.txt
Mã:
/ip firewall filter
add action=add-src-to-address-list address-list="Port Scan" address-list-timeout=4w2d chain=forward comment="Preventing Port Scan" protocol=tcp psd=21,3s,3,1
add action=add-src-to-address-list address-list="Port Scan" address-list-timeout=4w2d chain=input protocol=tcp psd=21,3s,3,1
add action=drop chain=forward src-address-list="Port Scan"
add action=drop chain=input src-address-list="Port Scan"

Dynamic IP problem with manual created routes (DHCP-Client).txt

Mã:
IP > DHCP Client > Select Interface > Advance Tabs > Script:

################################################################################################
:if ($bound=1) do={
    /ip route add distance=1 gateway=$"gateway-address" routing-mark=via-ISP2 comment="ISP2"
} else={
    /ip route remove [/ip route find comment="ISP2"]
}
################################################################################################


Preventing UDP Flood Attack.txt
Mã:
/ip firewall raw
add action=drop chain=prerouting comment="Preventing UDP Flood Attack" dst-port=53 in-interface=pppoe-out1 protocol=udp
add action=accept chain=prerouting dst-port=53 in-interface=!pppoe-out1 limit=100,5:packet protocol=udp
add action=drop chain=prerouting dst-port=53 in-interface=!pppoe-out1 protocol=udp


Go to IP > DNS and disable "Allow Remote Requests"

Preventing TCP SYN Attack.txt
Mã:
/ip firewall filter add chain=input protocol=tcp connection-limit=200,32 action=add-src-to-address-list  address-list=blocked-addr address-list-timeout=1d
/ip firewall filter add chain=input protocol=tcp src-address-list=blocked-addr connection-limit=3,32 action=tarpit
/ip firewall filter add chain=forward protocol=tcp tcp-flags=syn connection-state=new action=jump jump-target=SYN-Protect comment="SYN Flood protect" disabled=no
/ip firewall filter add chain=SYN-Protect protocol=tcp tcp-flags=syn limit=400,5 connection-state=new action=accept comment="" disabled=no
/ip firewall filter add chain=SYN-Protect protocol=tcp tcp-flags=syn connection-state=new action=drop comment="" disabled=no
/ip settings set tcp-syncookies=yes

Setting the Bandwidth Priority in the Microsoft Teams Application on MikroTik RouterOS.txt
Mã:
/ip firewall mangle
add action=mark-connection chain=prerouting comment="Mark MicrosoftTeams Application Connection" dst-address-list=MicrosoftTeams dst-port=3478,3479,3480,3481 new-connection-mark=MicrosoftTeams-Connection passthrough=yes protocol=tcp
add action=mark-connection chain=prerouting dst-address-list=MicrosoftTeams dst-port=3478,3479,3480,3481 new-connection-mark=MicrosoftTeams-Connection passthrough=yes protocol=udp
add action=mark-connection chain=prerouting comment="Mark MicrosoftTeams Web App Connections" dst-address-list=MicrosoftTeams dst-port=80,443 new-connection-mark=MicrosoftTeams-Connection passthrough=yes protocol=tcp
add action=mark-packet chain=prerouting comment="Mark All MicrosoftTeams Packets" connection-mark=MicrosoftTeams-Connection new-packet-mark=MicrosoftTeams-Packet passthrough=no

/queue simple
add comment="Internet Package (Upload Speed: 300 Mbps, Download Speed: 300 Mbps)" max-limit=300M/300M name=Parent_Queue target=192.168.50.0/24
add comment="Share Speed  to MicrosoftTeams (Upload Speed: 20Mbps, Download Speed: 20Mbps)" max-limit=20M/20M name=Queue_MicrosoftTeams packet-marks=MicrosoftTeams-Packet parent=Parent_Queue priority=1/1 target=192.168.50.0/24
add comment="Share Speed For General Working (Upload Speed: 280 Mbps, Download Speed: 280Mbps)" max-limit=280M/280M name=Queue_Other packet-marks=no-mark parent=Parent_Queue target=192.168.50.0/24

/ip firewall address-list
add address=13.107.64.0/18 list=MicrosoftTeams
add address=52.112.0.0/14 list=MicrosoftTeams
add address=52.120.0.0/14 list=MicrosoftTeams
add address=52.238.119.141/32 list=MicrosoftTeams
add address=52.244.160.207/32 list=MicrosoftTeams

Setting the Bandwidth Priority in the Zoom Video Conferencing Application on MikroTik RouterOS.txt
Mã:
/ip firewall mangle
add action=mark-connection chain=prerouting comment="Mark Zoom Application Connections" dst-address-list=Zoom dst-port=3478,3479,5090,5091,8801-8810 new-connection-mark=Zoom-Connection passthrough=yes protocol=tcp
add action=mark-connection chain=prerouting dst-address-list=Zoom dst-port=3478,3479,5090,5091,8801-8810 new-connection-mark=Zoom-Connection passthrough=yes protocol=udp
add action=mark-connection chain=prerouting comment="Mark Zoom Web App Connections" dst-address-list=Zoom dst-port=80,443 new-connection-mark=Zoom-Connection passthrough=yes protocol=tcp
add action=mark-packet chain=prerouting comment="Mark All Zoom Packets" connection-mark=Zoom-Connection new-packet-mark=Zoom-Packet passthrough=no

/queue simple
add comment="Internet Package (Upload Speed: 300 Mbps, Download Speed: 300 Mbps)" max-limit=300M/300M name=Parent_Queue target=192.168.50.0/24
add comment="Share Speed  to Zoom (Upload Speed: 20Mbps, Download Speed: 20Mbps)" max-limit=20M/20M name=Queue_Zoom packet-marks=Zoom-Packet parent=Parent_Queue priority=1/1 target=192.168.50.0/24
add comment="Share Speed For General Working (Upload Speed: 280 Mbps, Download Speed: 280Mbps)" max-limit=280M/280M name=Queue_Other packet-marks=no-mark parent=Parent_Queue target=192.168.50.0/24

/ip firewall address-list
add address=3.7.35.0/25    list=Zoom
add address=3.21.137.128/25 list=Zoom
add address=3.22.11.0/24 list=Zoom
add address=3.23.93.0/24 list=Zoom
add address=3.25.41.128/25 list=Zoom
add address=3.25.42.0/25 list=Zoom
add address=3.25.49.0/24 list=Zoom
add address=3.80.20.128/25 list=Zoom
add address=3.96.19.0/24 list=Zoom
add address=3.101.32.128/25 list=Zoom
add address=3.101.52.0/25 list=Zoom
add address=3.104.34.128/25 list=Zoom
add address=3.120.121.0/25 list=Zoom
add address=3.127.194.128/25 list=Zoom
add address=3.208.72.0/25 list=Zoom
add address=3.211.241.0/25 list=Zoom
add address=3.235.69.0/25 list=Zoom
add address=3.235.82.0/23 list=Zoom
add address=3.235.71.128/25 list=Zoom
add address=3.235.72.128/25 list=Zoom
add address=3.235.73.0/25 list=Zoom
add address=3.235.96.0/23 list=Zoom
add address=4.34.125.128/25 list=Zoom
add address=4.35.64.128/25 list=Zoom
add address=8.5.128.0/23 list=Zoom
add address=13.52.6.128/25 list=Zoom
add address=13.52.146.0/25 list=Zoom
add address=18.157.88.0/24 list=Zoom
add address=18.205.93.128/25 list=Zoom
add address=20.203.158.80/28 list=Zoom
add address=20.203.190.192/26 list=Zoom
add address=50.239.202.0/23 list=Zoom
add address=50.239.204.0/24 list=Zoom
add address=52.61.100.128/25 list=Zoom
add address=52.202.62.192/26 list=Zoom
add address=52.215.168.0/25 list=Zoom
add address=64.125.62.0/24 list=Zoom
add address=64.211.144.0/24 list=Zoom
add address=64.224.32.0/19 list=Zoom
add address=65.39.152.0/24 list=Zoom
add address=69.174.57.0/24 list=Zoom
add address=69.174.108.0/22 list=Zoom
add address=99.79.20.0/25 list=Zoom
add address=101.36.167.0/24 list=Zoom
add address=103.122.166.0/23 list=Zoom
add address=111.33.115.0/25 list=Zoom
add address=111.33.181.0/25 list=Zoom
add address=115.110.154.192/26 list=Zoom
add address=115.114.56.192/26 list=Zoom
add address=115.114.115.0/26 list=Zoom
add address=115.114.131.0/26 list=Zoom
add address=120.29.148.0/24 list=Zoom
add address=129.151.0.0/19 list=Zoom
add address=129.151.40.0/22 list=Zoom
add address=129.151.48.0/20 list=Zoom
add address=129.159.0.0/20 list=Zoom
add address=129.159.160.0/19 list=Zoom
add address=129.159.208.0/20 list=Zoom
add address=130.61.164.0/22 list=Zoom
add address=134.224.0.0/16 list=Zoom
add address=140.238.128.0/24 list=Zoom
add address=140.238.232.0/22 list=Zoom
add address=144.195.0.0/16 list=Zoom
add address=147.124.96.0/19 list=Zoom
add address=149.137.0.0/17 list=Zoom
add address=150.230.224.0/21 list=Zoom
add address=152.67.20.0/24 list=Zoom
add address=152.67.118.0/24 list=Zoom
add address=152.67.168.0/22 list=Zoom
add address=152.67.180.0/24 list=Zoom
add address=152.67.184.0/22 list=Zoom
add address=152.67.240.0/21 list=Zoom
add address=152.70.224.0/21 list=Zoom
add address=156.45.0.0/17 list=Zoom
add address=158.101.64.0/24 list=Zoom
add address=158.101.184.0/22 list=Zoom
add address=160.1.56.128/25 list=Zoom
add address=161.199.136.0/22 list=Zoom
add address=162.12.232.0/22 list=Zoom
add address=162.255.36.0/22 list=Zoom
add address=165.254.88.0/23 list=Zoom
add address=166.108.64.0/18 list=Zoom
add address=168.138.16.0/22 list=Zoom
add address=168.138.48.0/24 list=Zoom
add address=168.138.56.0/21 list=Zoom
add address=168.138.72.0/24 list=Zoom
add address=168.138.74.0/25 list=Zoom
add address=168.138.80.0/21 list=Zoom
add address=168.138.96.0/22 list=Zoom
add address=168.138.116.0/22 list=Zoom
add address=168.138.244.0/24 list=Zoom
add address=170.114.0.0/16 list=Zoom
add address=173.231.80.0/20 list=Zoom
add address=192.204.12.0/22 list=Zoom
add address=193.122.16.0/20 list=Zoom
add address=193.122.32.0/20 list=Zoom
add address=193.122.208.0/20 list=Zoom
add address=193.122.224.0/20 list=Zoom
add address=193.122.240.0/20 list=Zoom
add address=193.123.0.0/19 list=Zoom
add address=193.123.40.0/21 list=Zoom
add address=193.123.128.0/19 list=Zoom
add address=193.123.168.0/21 list=Zoom
add address=193.123.192.0/19 list=Zoom
add address=198.251.128.0/17 list=Zoom
add address=202.177.207.128/27 list=Zoom
add address=204.80.104.0/21 list=Zoom
add address=204.141.28.0/22 list=Zoom
add address=206.247.0.0/16 list=Zoom
add address=207.226.132.0/24 list=Zoom
add address=209.9.211.0/24 list=Zoom
add address=209.9.215.0/24 list=Zoom
add address=213.19.144.0/24 list=Zoom
add address=213.19.153.0/24 list=Zoom
add address=213.244.140.0/24 list=Zoom
add address=221.122.88.64/27 list=Zoom
add address=221.122.88.128/25 list=Zoom
add address=221.122.89.128/25 list=Zoom
add address=221.123.139.192/27 list=Zoom

Preventing Port Scanner.txt

Mã:
/ip firewall filter
add chain=input src-address-list="port scanners" action=drop comment="dropping port scanners" disabled=no
add chain=input protocol=tcp psd=21,3s,3,1 action=add-src-to-address-list address-list="port scanners" address-list-timeout=2w comment="Port scanners to list " disabled=no
add chain=input protocol=tcp tcp-flags=fin,!syn,!rst,!psh,!ack,!urg action=add-src-to-address-list address-list="port scanners" address-list-timeout=2w comment="NMAP FIN Stealth scan"
add chain=input protocol=tcp tcp-flags=fin,syn action=add-src-to-address-list address-list="port scanners" address-list-timeout=2w comment="SYN/FIN scan"
add chain=input protocol=tcp tcp-flags=syn,rst action=add-src-to-address-list address-list="port scanners" address-list-timeout=2w comment="SYN/RST scan"
add chain=input protocol=tcp tcp-flags=fin,psh,urg,!syn,!rst,!ack action=add-src-to-address-list address-list="port scanners" address-list-timeout=2w comment="FIN/PSH/URG scan"
add chain=input protocol=tcp tcp-flags=fin,syn,rst,psh,ack,urg action=add-src-to-address-list address-list="port scanners" address-list-timeout=2w comment="ALL/ALL scan"
add chain=input protocol=tcp tcp-flags=!fin,!syn,!rst,!psh,!ack,!urg action=add-src-to-address-list address-list="port scanners" address-list-timeout=2w comment="NMAP NULL scan"

Preventing ICMP Smurf Attack.txt

Mã:
/ip firewall raw
add action=drop chain=prerouting comment="Preventing ICMP Smurf Attack" dst-address-type=broadcast protocol=icmp
/ip firewall filter
add action=drop chain=input comment="Block Ping (ICMP) From WAN" in-interface=pppoe-out1 protocol=icmp

Preventing Brute Force Attack.txt

Mã:
/ip firewall filter
add action=drop chain=input comment="Drop anyone in Black List (SSH)" src-address-list="Black List (SSH)"
add action=jump chain=input comment="Jump to Black List (SSH) Chain" dst-port=22 jump-target="Black List (SSH) Chain" protocol=tcp
add action=add-src-to-address-list address-list="Black List (SSH)" address-list-timeout=4w2d chain="Black List (SSH) Chain" comment="Transfer repeated attempts from Black List (SSH) Stage 3 to Black List (SSH)" connection-state=new src-address-list="Black List (SSH) Stage 3"
add action=add-src-to-address-list address-list="Black List (SSH) Stage 3" address-list-timeout=1m chain="Black List (SSH) Chain" comment="Add Successive attempts to Black List (SSH) Stage 3" connection-state=new src-address-list="Black List (SSH) Stage 2"
add action=add-src-to-address-list address-list="Black List (SSH) Stage 2" address-list-timeout=1m chain="Black List (SSH) Chain" comment="Add Successive attempts to Black List (SSH) Stage 2" connection-state=new src-address-list="Black List (SSH) Stage 1"
add action=add-src-to-address-list address-list="Black List (SSH) Stage 1" address-list-timeout=1m chain="Black List (SSH) Chain" comment="Add initial attempt to Black List (SSH) Stage 1" connection-state=new
add action=return chain="Black List (SSH) Chain" comment="Return from Black List (SSH) chain"

Port Knocking Security.txt​


Mã:
/ip firewall filter
add action=accept chain=input comment="Port Knocking Security" connection-state=established,related
add action=add-src-to-address-list address-list=Temporary address-list-timeout=1m chain=input dst-port=1234 protocol=tcp
add action=add-src-to-address-list address-list=Valid address-list-timeout=1m chain=input dst-port=4321 protocol=tcp src-address-list=Temporary
add action=accept chain=input src-address-list=Valid
add action=drop chain=input
 
Chat với người lạ
Trợ Giúp Users
  • Không có ai đang trò chuyện vào lúc này.
    @ batboyboy: you welcome!
    • Chúng tôi tôn trọng sự riêng tư của bạn

      Chúng tôi sử dụng cookie cần thiết để giúp trang web này hoạt động và các cookie tùy chọn để nâng cao trải nghiệm của bạn.

      Xem thêm thông tin và định cấu hình tùy chọn của bạn

      These cookies are required to enable core functionality such as security, network management, and accessibility. You may not reject these.
      We deliver enhanced functionality for your browsing experience by setting these cookies. If you reject them, enhanced functionality will be unavailable.
      Cookies set by third parties may be required to power functionality in conjunction with various service providers for security, analytics, performance or advertising purposes.
    Bên trên