Cấu hình cơ bản Mikrotik

Thứ tư - 26/07/2023 22:18 353 0
Cấu hình cơ bản cho Mikrotik, gán địa chỉ IP, DNS, NTP, SNMP, rule firewall block đăng nhập sai sau 3 lần....
Mikrotik
Mikrotik
Đặt Name cho thiết bị: thay TenThietBi bằng tên thiết bị muốn đặt
/system identity
set name=TenThietBi

Gán địa chỉ IP vào interface ether2 : Thay các thông tin cần thiết như tên interface, địa chỉ IP, network cho môi trường thiết lập
/ip address
add address=123.123.123.123/24 interface=ether2 network=123.123.123.123.0

Cài đặt DNS Server : Thay ip dns theo môi trường cài đặt
/ip dns
set servers=8.8.8.8

Tắt các dịch vụ không cần thiết : trong danh sách ip service, chỉ cho phép sử dụng winbox, nếu muốn dùng thêm dịch vụ như ssh thì xóa nó khỏi lệnh dưới
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set ssh disabled=yes
set api disabled=yes
set api-ssl disabled=yes

Cấu hình SNMP chỉ cho phép địa chỉ 123.123.123.123 lấy thông tin SNMP, thay các tham số như IP, SNMP string contact phù hợp với môi trường
/snmp community
add addresses=123.123.123.123/32 name=SNMPString
/snmp
set contact=nxcuong@ued.vn enabled=yes location=Da-Nang trap-community=SNMPString

Cấu hình NTP: Nếu địa chỉ NTP Server là IP thì thay vào, Nếu không thiết lập DNS ở trên thì phải dùng địa chỉ IP
/system clock
set time-zone-name=Asia/Ho_Chi_Minh
/system ntp client
set enabled=yes
/system ntp client servers
add address=1.vn.pool.ntp.org


Firewall

Tạo bộ lọc firewall chặn IPv4 sau 3 lần đăng nhập sai mật khẩu đối với các port 22,80,8291
/ip firewall filter
add action=drop chain=input dst-port=22,80,8291 protocol=tcp \
    src-address-list=Deny_Address
add action=add-src-to-address-list address-list=Deny_Address \
    address-list-timeout=1w3d chain=input connection-state=new dst-port=\
    22,80,8291 log=yes protocol=tcp src-address-list=Attempt_3
add action=add-src-to-address-list address-list=Attempt_3 address-list-timeout=1m \
    chain=input connection-state=new dst-port=22,80,8291 log=yes protocol=tcp \
    src-address-list=Attempt_2
add action=add-src-to-address-list address-list=Attempt_2 address-list-timeout=1m \
    chain=input connection-state=new dst-port=22,80,8291 log=yes protocol=tcp \
    src-address-list=Attempt_1
add action=add-src-to-address-list address-list=Attempt_1 address-list-timeout=1m \
    chain=input connection-state=new dst-port=22,80,8291 log=yes protocol=tcp

Tạo bộ lọc firewall chặn IPv6 sau 3 lần đăng nhập sai mật khẩu
/ipv6 firewall 
add action=drop chain=input dst-port=22,80,8291 protocol=tcp \
    src-address-list=Deny_Address
add action=add-src-to-address-list address-list=Deny_Address \
    address-list-timeout=1w3d chain=input connection-state=new dst-port=\
    22,80,8291 log=yes protocol=tcp src-address-list=Attempt_3
add action=add-src-to-address-list address-list=Attempt_3 address-list-timeout=1m \
    chain=input connection-state=new dst-port=22,80,8291 log=yes protocol=tcp \
    src-address-list=Attempt_2
add action=add-src-to-address-list address-list=Attempt_2 address-list-timeout=1m \
    chain=input connection-state=new dst-port=22,80,8291 log=yes protocol=tcp \
    src-address-list=Attempt_1
add action=add-src-to-address-list address-list=Attempt_1 address-list-timeout=1m \
    chain=input connection-state=new dst-port=22,80,8291 log=yes protocol=tcp


Phát hiện và phòng chống DDOS

Chuyển các kết nối mới sang DDoS_Detection
/ip firewall filter
add chain=forward connection-state=new action=jump jump-target=DDoS_Detection

So sánh địa chỉ nguồn và địa chỉ đích trên mỗi giây, nếu vượt 32 gói trên mỗi giây thì sẽ cập nhật ip nguồn và ip đích vào DDoS_Detection
/ip firewall filter
add chain=DDoS_Detection dst-limit=32,32,src-and-dst-address/1s action=return
/ip firewall filter
add chain=DDoS_Detection action=add-dst-to-address-list address-list=IPs_Victim address-list-timeout=10m
add chain=DDoS_Detection action=add-src-to-address-list address-list=IPs_DDOS_attack address-list-timeout=10m

Những IP nào có trong danh sách IPs_DDOS_attack - tớiIPs_Victim đều chặn lại hoàn toàn.
/ip firewall filter
add chain=forward connection-state=new src-address-list=IPs_DDOS_attack dst-address-list=IPs_Victim action=drop

Tổng số điểm của bài viết là: 0 trong 0 đánh giá

Click để đánh giá bài viết
Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây