در این کارت، راهنمای کامل ایمنسازی MikroTik شامل تنظیمات فایروال، سرویسها، امنیت SSH، Winbox، VPN، اسکریپتهای آماده، و چکلیست نهایی قرار دارد.
برای دریافت نسخه کامل مقاله، شامل اسکریپتهای آماده Terminal، فایروال حرفهای، امنیت لایه سرویسها و VPN، روی دکمه زیر کلیک کنید.
روترهای MikroTik به دلیل قیمت مناسب، امکانات گسترده و قدرت بالا، در بسیاری از شبکههای سازمانی، شرکتها، ISPها و حتی منازل استفاده میشوند. همین محبوبیت باعث شده هدف رایج حملات سایبری باشند. هکرها معمولاً از پورتهای باز، رمزهای ضعیف، سرویسهای بلااستفاده و پیکربندیهای نادرست سوءاستفاده میکنند.
دستورهای زیر سرویسهای پرخطر را خاموش میکنند:
/system service disable telnet
/system service disable ftp
/system service disable api
/system service set winbox address=YOUR-IP/32
/system service set ssh address=YOUR-IP/32
اسکریپت کامل ضد حملات Bruteforce روی Winbox، SSH و WebFig:
/ip firewall filter
add chain=input protocol=tcp dst-port=22,8291,80,8728 connection-state=new src-address-list=blacklist action=drop
add chain=input protocol=tcp dst-port=22,8291,80,8728 connection-state=new src-address-list=stage1 limit=20,5 action=add-src-to-address-list address-list=stage2 timeout=5m
add chain=input protocol=tcp dst-port=22,8291,80,8728 connection-state=new src-address-list=stage2 limit=5,5 action=add-src-to-address-list address-list=blacklist timeout=1d
/system logging add topics=firewall action=memory
/system logging add topics=critical action=memory
/system logging add topics=account action=memory
این اسکریپت کاملترین نسخه برای امنسازی فوری یک MikroTik است:
# ایجاد یک پروفایل امنیتی
/user set 0 password=STRONGPASS
/system clock set time-zone-name=Asia/Tehran
/ip service disable telnet,ftp,api
/ip ssh set strong-crypto=yes
/ip firewall filter add chain=input protocol=tcp dst-port=8291 action=drop src-address-list=blacklist
/ip firewall filter add chain=input protocol=tcp dst-port=22 action=drop src-address-list=blacklist
/ip firewall address-list add list=safe address=YOUR-IP/32
/system package update check-for-updates
/system package update install
حملات DDoS یکی از رایجترین روشهای از کار انداختن سرویسها هستند. میکروتیک ابزارهای قدرتمندی برای مقابله با آن ارائه میدهد.
/ip firewall filter # جلوگیری از UDP Flood add chain=input protocol=udp action=drop connection-state=new src-address-list=ddos-attackers add chain=input protocol=udp limit=50,10 action=accept add chain=input protocol=udp action=add-src-to-address-list address-list=ddos-attackers timeout=10m # جلوگیری از SYN Flood add chain=input protocol=tcp tcp-flags=syn limit=20,10 action=accept add chain=input protocol=tcp tcp-flags=syn action=drop # جلوگیری از ICMP Flood add chain=input protocol=icmp limit=10,5 action=accept add chain=input protocol=icmp action=drop
یکی از خطرناکترین حملات داخل شبکه، جعل DHCP و ایجاد DHCP سرور جعلی است.
/interface bridge settings set use-ip-firewall=yes /ip dhcp-server alert add interface=bridge1 alert-timeout=10m on-alert=dhcp-alert
در این حالت اگر یک DHCP غیرمجاز شناسایی شود، سیستم هشدار امنیتی ثبت میکند.
/ip firewall filter add chain=input protocol=udp dst-port=67 action=drop in-interface=ether1
برای جلوگیری از حملات ARP Poisoning که موجب حمله Man-in-the-Middle میشود، تنظیمات زیر ضروری است:
/interface bridge port set [find] arp=reply-only /ip arp add address=192.168.1.1 mac-address=AA:BB:CC:DD:EE:FF interface=bridge1
پروتکلهای همسایگی مثل CDP، LLDP و MNDP باعث افشای اطلاعات روتر شما میشوند.
/ip neighbor discovery-settings set discover-interface-list=none
رمزهای ضعیف، مهمترین عامل هک شدن میکروتیک هستند.
/user set admin disabled=yes /user add name=secure password=STRONG-PASS group=full
با این اسکریپت، هر ۱۲ ساعت یک نسخه رمزگذاری شده از تنظیمات ذخیره میشود:
/system scheduler add interval=12h name=auto-backup on-event="/system backup save name=auto-secure-backup" policy=read,write,test
فایروال میکروتیک قلب امنیت شبکه محسوب میشود. در این بخش به مجموعهای از قوانین و الگوهای حرفهای برای حفاظت لایهای (Layered Security) میپردازیم.
/ip firewall filter add chain=input protocol=tcp psd=21,3s,3,1 action=drop comment="Drop port scanners" add chain=input protocol=tcp tcp-flags=fin,!syn,!rst,!ack action=drop comment="Invalid FIN scan" add chain=input protocol=tcp tcp-flags=fin,syn action=drop comment="FIN/SYN scan" add chain=input protocol=tcp tcp-flags=syn,rst action=drop comment="SYN/RST scan" add chain=input protocol=tcp tcp-flags=fin,psh,urg action=drop comment="XMAS scan"
Brute Force یکی از شایعترین حملات روی روترها است. در ادامه اسکریپت کامل Drop کردن IPهای مهاجم روی SSH، Winbox و API آورده شده.
/ip firewall filter add chain=input protocol=tcp dst-port=22 connection-state=new src-address-list=ssh_blacklist action=drop add chain=input protocol=tcp dst-port=22 connection-state=new src-address-list=ssh_stage action=add-src-to-address-list address-list=ssh_blacklist address-list-timeout=1d add chain=input protocol=tcp dst-port=22 connection-state=new action=add-src-to-address-list address-list=ssh_stage address-list-timeout=1m # همین ساختار برای Winbox و API add chain=input protocol=tcp dst-port=8291 connection-state=new src-address-list=winbox_blacklist action=drop add chain=input protocol=tcp dst-port=8291 connection-state=new src-address-list=winbox_stage action=add-src-to-address-list address-list=winbox_blacklist address-list-timeout=1d add chain=input protocol=tcp dst-port=8291 connection-state=new action=add-src-to-address-list address-list=winbox_stage address-list-timeout=1m
مدیریت اشتباه کاربران دسترسی مستقیم به روتر را به خطر میاندازد. در ادامه اصول حرفهای آمده است:
/system logging add topics=account,info action=memory add topics=account action=echo add topics=account action=remote remote=10.10.10.10
بسیاری از حملات در شبکه داخلی انجام میشود: حملات ARP، DHCP، MAC Spoofing و …
/interface ethernet set ether1 arp=reply-only
این گزینه فقط به IPهای تعریفشده در Bindings اجازه ارتباط میدهد.
/ip dhcp-server set dhcp1 authoritative=yes
این کار از DHCP Rogue جلوگیری میکند.
/interface bridge settings set use-ip-firewall=yes
/interface wireless access-list add mac-address=AA:BB:CC:DD:EE:FF interface=wlan1 comment="Trusted Device"
در این بخش، یک اسکریپت کامل برای امنسازی فوری MikroTik ارائه شده است:
# Disable unnecessary services /ip service set telnet disabled=yes set ftp disabled=yes set www disabled=yes set api disabled=yes # Enable logging /system logging add topics=info action=memory # Drop invalid packets /ip firewall filter add chain=input connection-state=invalid action=drop # Protect Winbox /ip firewall filter add chain=input protocol=tcp dst-port=8291 src-address-list=allowed_winbox action=accept add chain=input protocol=tcp dst-port=8291 action=drop
در صورت هرگونه سؤال درباره امنیت شبکه یا MikroTik میتوانید از چتبات سایت کمک بگیرید یا از بخش مشاوره رایگان با کارشناسان ما ارتباط برقرار کنید.
با اجرای این دستورها و نکات، روترهای MikroTik شما در برابر رایجترین حملات ایمن خواهند شد و احتمال نفوذ تا حد زیادی کاهش پیدا میکند.