Bài Viết Tiêu Biểu

Thủ thuật quay nhiều kết nối PPPoE cùng lúc với VRRP trong MikroTik.

VRRP (Virtual Router Redundancy Protocol) trong MikroTik là một giao thức định tuyến dự phòng để đảm bảo tính khả dụng của đường mạng bằng cách sử dụng nhiều router ảo để thay thế cho một router thật.

Với VRRP, nhiều thiết bị định tuyến có thể được cấu hình để làm việc cùng nhau để tạo ra một nhóm router ảo. Mỗi router ảo được chỉ định một địa chỉ IP và một router ảo chính được chỉ định để xử lý lưu lượng mạng. Nếu router ảo chính gặp sự cố, router ảo phụ sẽ tiếp quản địa chỉ IP và xử lý lưu lượng mạng thay thế.

VRRP trong MikroTik được sử dụng để cung cấp tính khả dụng cao cho đường mạng và đảm bảo rằng các dịch vụ mạng vẫn được cung cấp một cách liên tục, ngay cả khi có sự cố xảy ra với thiết bị định tuyến chính.

Với VRRP, bạn có thể cấu hình một nhóm router ảo với nhiều thiết bị định tuyến để tạo ra một mạng định tuyến dự phòng. Các kết nối PPPoE được thiết lập giữa các thiết bị định tuyến và khách hàng của bạn.

Mỗi thiết bị định tuyến trong nhóm VRRP có thể cấu hình để chạy các dịch vụ PPPoE, vì vậy khi bạn kết nối với địa chỉ IP của router ảo, nó sẽ tự động chuyển hướng kết nối đến thiết bị định tuyến nào đang được chỉ định làm router ảo chính trong nhóm.

Vì vậy, dù bạn đang sử dụng một hoặc nhiều kết nối PPPoE, bạn có thể cấu hình VRRP để tạo ra một mạng định tuyến dự phòng và đảm bảo tính khả dụng cao cho đường mạng của mình.

Đặt Ip cho cổng Ethernet1 :192.168.168.1/24 và chạy DHCP ether1 (port thực hiện bridge từ modem nhà mạng).

/interface vrrp
 
add interface=ether1 mtu=1480 name=vrrp1 preemption-mode=no priority=255 \
 
vrid=10
 
add interface=ether1 mtu=1480 name=vrrp2 preemption-mode=no priority=255 \
 
vrid=11
 
add interface=ether1 mtu=1480 name=vrrp3 preemption-mode=no priority=255 \
 
vrid=12
 
/ip pool
 
add name=dhcp_pool4 ranges=192.168.168.2-192.168.168.254
 
/ip address
 
add address=192.168.168.1/24 interface=ether1 network=192.168.168.0
 
add address=192.168.168.2 interface=vrrp1 network=192.168.168.2
 
add address=192.168.168.3 interface=vrrp2 network=192.168.168.3
 
add address=192.168.168.4 interface=vrrp3 network=192.168.168.4
 
/ip dhcp-server
 
add address-pool=dhcp_pool4 disabled=no interface=ether1 name=dhcp3

Đặt IP cho vrrp1= 192.168.168.2/32

Tương tự như trên mở thêm vrrp2, vrrp3…

Quay số pppoe  trên với các vrrp đã khai báo.

/interface pppoe-client
 
add add-default-route=yes disabled=no interface=ether1 name=pppoe-out1 \
 
password=12345678 user=ductv_ld01
 
add add-default-route=yes default-route-distance=2 disabled=no interface=\
 
vrrp1 name=pppoe-out2 password=12345678 user=ductv_ld01
 
add add-default-route=yes default-route-distance=3 disabled=no interface=\
 
vrrp2 name=pppoe-out3 password=12345678 user=ductv_ld01
 
add add-default-route=yes default-route-distance=4 disabled=no interface=\
 
vrrp3 name=pppoe-out4 password=12345678 user=ductv_ld01

Cân bằng tải gộp băng thông với pcc ở OS6

/ip firewall address-list
 
add address=192.168.10.0/24 list=LOCAL-IP
 
/ip firewall mangle
 
add action=mark-connection chain=input in-interface=pppoe-out1 \
 
new-connection-mark=cm-pppoe-out1 passthrough=yes
 
add action=mark-connection chain=input in-interface=pppoe-out2 \
 
new-connection-mark=cm-pppoe-out2 passthrough=yes
 
add action=mark-connection chain=input in-interface=pppoe-out3 \
 
new-connection-mark=cm-pppoe-out3 passthrough=yes
 
add action=mark-connection chain=input in-interface=pppoe-out4 \
 
new-connection-mark=cm-pppoe-out4 passthrough=yes
 
add action=mark-connection chain=prerouting dst-address-list=!LOCAL-IP \
 
dst-address-type=!local new-connection-mark=cm-pppoe-out1 passthrough=yes \
 
per-connection-classifier=both-addresses-and-ports:4/0 src-address-list=\
 
LOCAL-IP
 
add action=mark-connection chain=prerouting dst-address-list=!LOCAL-IP \
 
dst-address-type=!local new-connection-mark=cm-pppoe-out2 passthrough=yes \
 
per-connection-classifier=both-addresses-and-ports:4/1 src-address-list=\
 
LOCAL-IP
 
add action=mark-connection chain=prerouting dst-address-list=!LOCAL-IP \
 
dst-address-type=!local new-connection-mark=cm-pppoe-out3 passthrough=yes \
 
per-connection-classifier=both-addresses-and-ports:4/2 src-address-list=\
 
LOCAL-IP
 
add action=mark-connection chain=prerouting dst-address-list=!LOCAL-IP \
 
dst-address-type=!local new-connection-mark=cm-pppoe-out4 passthrough=yes \
 
per-connection-classifier=both-addresses-and-ports:4/3 src-address-list=\
 
LOCAL-IP
 
add action=mark-routing chain=prerouting connection-mark=cm-pppoe-out1 \
 
dst-address-list=!LOCAL-IP new-routing-mark=to-pppoe-out1 passthrough=yes \
 
src-address-list=LOCAL-IP
 
add action=mark-routing chain=prerouting connection-mark=cm-pppoe-out2 \
 
dst-address-list=!LOCAL-IP new-routing-mark=to-pppoe-out2 passthrough=yes \
 
src-address-list=LOCAL-IP
 
add action=mark-routing chain=prerouting connection-mark=cm-pppoe-out3 \
 
dst-address-list=!LOCAL-IP new-routing-mark=to-pppoe-out3 passthrough=yes \
 
src-address-list=LOCAL-IP
 
add action=mark-routing chain=prerouting connection-mark=cm-pppoe-out4 \
 
dst-address-list=!LOCAL-IP new-routing-mark=to-pppoe-out4 passthrough=yes \
 
src-address-list=LOCAL-IP
 
add action=mark-routing chain=output connection-mark=cm-pppoe-out1 \
 
new-routing-mark=to-pppoe-out1 passthrough=yes
 
add action=mark-routing chain=output connection-mark=cm-pppoe-out2 \
 
new-routing-mark=to-pppoe-out2 passthrough=yes
 
add action=mark-routing chain=output connection-mark=cm-pppoe-out3 \
 
new-routing-mark=to-pppoe-out3 passthrough=yes
 
add action=mark-routing chain=output connection-mark=cm-pppoe-out4 \
 
new-routing-mark=to-pppoe-out4 passthrough=yes
 
/ip firewall nat
 
add action=masquerade chain=srcnat out-interface=pppoe-out1
 
add action=masquerade chain=srcnat out-interface=pppoe-out2
 
add action=masquerade chain=srcnat out-interface=pppoe-out3
 
add action=masquerade chain=srcnat out-interface=pppoe-out4
 
/ip route
 
add check-gateway=ping distance=1 gateway=pppoe-out1 routing-mark=\
 
to-pppoe-out1
 
add check-gateway=ping distance=1 gateway=pppoe-out2 routing-mark=\
 
to-pppoe-out2
 
add check-gateway=ping distance=1 gateway=pppoe-out3 routing-mark=\
 
to-pppoe-out3
 
add check-gateway=ping distance=1 gateway=pppoe-out4 routing-mark=\
 
to-pppoe-out4
 
add check-gateway=ping distance=1 gateway=pppoe-out1
 
add check-gateway=ping distance=2 gateway=pppoe-out2
 
add check-gateway=ping distance=3 gateway=pppoe-out3
 
add check-gateway=ping distance=4 gateway=pppoe-out4

Lưu ý: sửa lại lớp mạng phù hợp ở address-list để lệnh được chạy chính xác.

Cân bằng tải gộp băng thông với pcc ở OS7

/ip firewall address-list
add address=192.168.0.0/16 list=LOCAL-IP
/ip firewall nat
add chain=srcnat out-interface="pppoe-out1" action=masquerade
add chain=srcnat out-interface="pppoe-out2" action=masquerade
add chain=srcnat out-interface="pppoe-out4" action=masquerade
add chain=srcnat out-interface="pppoe-out4" action=masquerade
/routing table
add name="to-pppoe-out1" fib
add name="to-pppoe-out2" fib
add name="to-pppoe-out4" fib
add name="to-pppoe-out4" fib
/ip route
add check-gateway=ping distance=1 gateway="0.0.0.0/0" routing-table="to-pppoe-out1"
add check-gateway=ping distance=1 gateway="0.0.0.0/0" routing-table="to-pppoe-out2"
add check-gateway=ping distance=1 gateway="0.0.0.0/0" routing-table="to-pppoe-out4"
add check-gateway=ping distance=1 gateway="0.0.0.0/0" routing-table="to-pppoe-out4"
add check-gateway=ping distance=1 gateway="0.0.0.0/0"
add check-gateway=ping distance=2 gateway="0.0.0.0/0"
add check-gateway=ping distance=3 gateway="0.0.0.0/0"
add check-gateway=ping distance=4 gateway="0.0.0.0/0"
/ip firewall mangle
add action=accept chain=prerouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP
add action=accept chain=postrouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP
add action=accept chain=forward dst-address-list=LOCAL-IP src-address-list=LOCAL-IP
add action=accept chain=input dst-address-list=LOCAL-IP src-address-list=LOCAL-IP
add action=accept chain=output dst-address-list=LOCAL-IP src-address-list=LOCAL-IP
add action=mark-connection chain=input in-interface="pppoe-out1" new-connection-mark="cm-pppoe-out1" passthrough=yes
add action=mark-connection chain=input in-interface="pppoe-out2" new-connection-mark="cm-pppoe-out2" passthrough=yes
add action=mark-connection chain=input in-interface="pppoe-out4" new-connection-mark="cm-pppoe-out4" passthrough=yes
add action=mark-connection chain=input in-interface="pppoe-out4" new-connection-mark="cm-pppoe-out4" passthrough=yes
add action=mark-routing chain=output connection-mark="cm-pppoe-out1" new-routing-mark="to-pppoe-out1" passthrough=yes
add action=mark-routing chain=output connection-mark="cm-pppoe-out2" new-routing-mark="to-pppoe-out2" passthrough=yes
add action=mark-routing chain=output connection-mark="cm-pppoe-out4" new-routing-mark="to-pppoe-out4" passthrough=yes
add action=mark-routing chain=output connection-mark="cm-pppoe-out4" new-routing-mark="to-pppoe-out4" passthrough=yes
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark="cm-pppoe-out1" passthrough=yes per-connection-classifier=both-addresses-and-ports:4/0 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark="cm-pppoe-out2" passthrough=yes per-connection-classifier=both-addresses-and-ports:4/1 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark="cm-pppoe-out4" passthrough=yes per-connection-classifier=both-addresses-and-ports:4/2 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark="cm-pppoe-out4" passthrough=yes per-connection-classifier=both-addresses-and-ports:4/3 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP
add action=mark-routing chain=prerouting connection-mark="cm-pppoe-out1" new-routing-mark="to-pppoe-out1" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP
add action=mark-routing chain=prerouting connection-mark="cm-pppoe-out2" new-routing-mark="to-pppoe-out2" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP
add action=mark-routing chain=prerouting connection-mark="cm-pppoe-out4" new-routing-mark="to-pppoe-out4" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP
add action=mark-routing chain=prerouting connection-mark="cm-pppoe-out4" new-routing-mark="to-pppoe-out4" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP

Chúc bạn may mắn – Thành công với cấu hình trên.

Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *