222

Mikrotik Config : LoadBalance PPC 2 WAN (Static IP) to 1LAN



1.  ดาวน์โหลด Winbox แล้วเสียบสาย LAN เข้าที่ Port Ether3 ของ MikroTik หลังจากนั้นเข้าโปรแกรม Winbox แล้วคลิกเลือก mac address MikroTik  แล้วกด Connect

รูปภาพ

2.  ปกติแล้ว MikroTik แทบทุกรุ่นจะมี config default ให้ แต่เราจะไม่ใช่ครับ กด Remove Configuration ได้เลย ถ้าได้เคยทำการ config มาแล้ว ให้ทำการ reset config ที่เมนู System > Reset Configuration หลังจากนั้นจึงค่อยทำการ Remove config default ตามรูป
 
รูปภาพ
 
          เมื่อ Remove config default แล้ว Mikrotik จะทำการ Restart ตัวเอง หลังจากนั้นให้ ทำการ Connect Winbox อีกครั้งหนึ่ง


3.  จากนั้นทำการตรวจสอบ Interface ทั้งทั้งหมด สังเกตุ ether3 จะมีตัว R แสดงว่าเชื่อมต่ออยู่ มี Tx/Rx วิ่ง

รูปภาพ

              จากนั้นให้ทำการเสียสาย Internet ทั้งสองเส้นเข้าที่ Port ether1 และ ether2 โดยตั้ง IP Internet ทั้งสองเส้นไม่ให้เป็นไอพีเดียวกัน ตัวอย่างเช่น
                         IP Rounter ตัวแรกเป็น 192.168.1.1
                         IP Rounter ตัวที่สองเป็น 192.168.2.1
เมื่อเตรียมการ Internet ทั้งสองเส้น เรียบร้อยแล้ว ให้ทำตามข้นตอนต่อไปได้เลยครับ
 

4.  เนื่องด้วยถ้าทำในรูปแบบ Interface นั้นขั้นตอนจะเยอะมาก ผมจึงใช้วิธี code ผ่าน Terminal โดยเข้าเมนู New Terminal > Terminal

รูปภาพ

5.  จากนั้นคัดลอก code ไปวางใน Ms Word เพื่อทำการแก้ไข IP ให้เข้ากับระบบของท่าน โดย IP ที่สีเขียว เป็นไอพีที่จะแจกให้ใช้ในในระบบ IP สีร้ำเงิน เป็น IP Internet เส้นแรก IP สีแดงเป็นไอพีเส้นที่สอง หรือ ท่านสามารดูได้จาก Comment ที่อยู่ในโค้ท เพื่อแก้ไข



/ip address add address=192.168.10.1/24 network=192.168.10.0 broadcast=192.168.10.255 interface=ether3
/ip address add address=192.168.1.200/24 network=192.168.1.0 broadcast=192.168.1.255 interface=ether1
/ip address add address=192.168.2.200/24 network=192.168.2.0 broadcast=192.168.2.255 interface=ether2
 

/ip firewall mangle add chain=input in-interface=ether1 action=mark-connection new-connection-mark=WAN1_conn
/ip firewall mangle add chain=input in-interface=ether2 action=mark-connection new-connection-mark=WAN2_conn
/ip firewall mangle add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
/ip firewall mangle add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2

/ip firewall mangle add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=ether3
/ip firewall mangle add chain=prerouting dst-address=192.168.10.0/24 action=accept in-interface=ether3
/ip firewall mangle add chain=prerouting connection-mark=WAN1_conn in-interface=ether3 action=mark-routing new-routing-mark=to_WAN1
/ip firewall mangle add chain=prerouting connection-mark=WAN2_conn in-interface=ether3 action=mark-routing new-routing-mark=to_WAN2


/ip firewall mangle add chain=prerouting dst-address-type=!local in-interface=ether3 per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
/ip firewall mangle add chain=prerouting dst-address-type=!local in-interface=ether3 per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes

 

/ip route add dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-mark=to_WAN1 check-gateway=ping
/ip route add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
/ip route add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 check-gateway=ping
/ip route add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping


/ip firewall nat add chain=srcnat out-interface=ether1 action=masquerade
/ip firewall nat add chain=srcnat out-interface=ether2 action=masquerade


/ip pool add name=default-dhcp ranges=192.168.10.50-192.168.10.200
/ip dhcp-server add name=default address-pool=default-dhcp interface=ether3 disabled=no
/ip dhcp-server network add address=192.168.10.0/24 gateway=192.168.10.1 dns-server=8.8.8.8 comment="default configuration"


/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000K max-udp-packet-size=512 servers=8.8.8.8,8.8.4.4
Previous
Next Post »