วันอังคารที่ 26 ธันวาคม พ.ศ. 2560

Allow IP TH Only MIKROTIK

https://www.ip2location.com/free/visitor-blocker

เลือก thailand
Ex
/ip firewall address-list add list=TH_list address=1.0.128.0/17
...
....
/ip firewall address-list add list=TH_list address=200.0.128.0/17
/ip firewall filter
add action=drop chain=input dst-port=53 in-interface=ether12 protocol=udp
add action=drop chain=input comment="Allow TH_list" in-interface=ether12 \
    protocol=udp src-address-list=!TH_list
add action=drop chain=input dst-port=53 in-interface=ether12 protocol=tcp

DNS Caching

DNS  Caching ให้ Client มา Request ขอใช้ DNS  ได้สักพัก
เมนู IP > DNS > Allow Remote Requests คือการเปิดใช้งาน DNS Caching Server เพื่อบริการ DNS กับเครื่องลูกข่าย
แต่ถ้าไม่กำหนด firewall อะไรเลย ก็เป็นการให้บริการกับคนทั้งโลก!!!  โอ… บริการของเรา ระดับโลกจริงๆ นะฮัฟฟ์ฟ์
หลังจากใช้งานไปสักพัก ก็เริ่มรู้สึกประหลาดใจกับ DNS Cache หน้าตาแปลกๆ 0.0.0.0  เอ… ที่ไหนก็ได้ เอ๊ะ.. กลิ่นชักไม่ดีแล้ว
ทดสอบ ลอง solve dns ด้วย real ip ของ Mikrotik ปรากฎว่า ทำได้??
การทดสอบง่ายๆ ใช้คำสั่ง
nslookup imhofocus.com real-ip-mikrotik
ตัวอย่าง
root@pollhsp2:~# nslookup www.imhofocus.com 11.22.33.44
Server:         11.22.33.44
Address:        11.22.33.44#53
Non-authoritative answer:
Name:   www.imhofocus.com
Address: 27.254.35.142
อื้ม… Mikrotik ที่ใช้ทำหน้าที่เป็น Gateway ของเรา เป็นผู้ให้บริการ Free DNS Cache ระดับโลกไปซะแล้ว
เปิดการป้องกัน!!!
เปิด New terminal แล้ววางสคริปต์นี้ลงไป ก่อนที่จะเอาไปใช้งานกัน ให้ก๊อปปี้คำสั่งลงใน Notepad แล้วแก้ไข in-interface ให้เป็น interface ที่ใช้ออกเน็ตนะครับ ถ้าเป็น pppoe-client ก็แก้ไขชื่อตามให้เรียบร้อย ก่อนที่จะวางคำสั่งลงไป
#ป้องกันการขอใช้ DNS Caching จากภายนอก อย่าลืมแก้ไข Interface ที่ใช้ต่อ internet ล่ะ
/ip firewall filter
add chain=input in-interface=ether11 protocol=udp dst-port=53 action=drop
add chain=input in-interface=ether11 protocol=tcp dst-port=53 action=drop
#ป้องกันการโดนทำ DHCP Relay จากภายนอก จัดไป
/ip firewall filter
add chain=forward protocol=udp dst-port=53 out-interface=!ether11 action=drop
add chain=forward protocol=tcp dst-port=53 out-interface=!ether11 action=drop
#ป้องกันเครื่องลูก กำหนด ip dns เอง ซึ่งจะมีผลทำให้บางคนไม่ได้หน้า login hotspot ในกรณีกำหนด splash screen แบบ domain name
/ip firewall nat
add chain=dstnat protocol=udp dst-port=53 in-interface=!ether11 action=redirect
add chain=dstnat protocol=tcp dst-port=53 in-interface=!ether11 action=redirect
ทดสอบซ้ำอีกที
root@pollhsp2:~# nslookup www.imhofocus.com 11.22.33.44
;; connection timed out; no servers could be reached
สำเร็จ เราป้องกัน Gateway ของเรา ออกจากการให้บริการระดับโลกได้สำเร็จ  จบครับ 😀
** ข้อควรระวัง การทดสอบการ solve dns ควรใช้เครื่องที่อยู่ภายนอกเน็ตเวิร์กที่จะทดสอบ เพื่อป้องกันการสับสนของผู้ทดสอบเอง **
Credit
http://forum.mikrotik.com/viewtopic.php?f=2&t=69677

วันศุกร์ที่ 1 ธันวาคม พ.ศ. 2560

เคยเจอปัญหา I phone I PAD เข้าใช้งาน Hotsport Mikrotik ไม่ได้อยู่หรือไม่ เรามีทางแก้

เคยเจอปัญหา I phone I PAD เข้าใช้งาน Hotsport Mikrotik ไม่ได้อยู่หรือไม่ เรามีทางแก้


ท่านเคยเจอปัญหา Iphone ipad login เข้าหน้า hot Spot ไม่ได้อยู่หรือไม่
ผมเคยอยู่ ตอนนั้น ลูกค้า login ไม่ได้ก็คิดว่าเป็นที่ มือถือของลูกค้าเครื่องเดียว ที่ไหนได้เป็นทั้ง หอพัก 
ผมเลยค้นหาใน Google ดูมีฝาหรั่งบอกมา ว่าเป็นเพราะ mikrotik Block Iphone ให้เรา ไป  Allow ที่ Walled garden ใน hotspot
ผมเลยเขียน เป็น Script  Add Web ทั้งหมดของ Apple ซะเลย

/ip hotspot walled-garden
add dst-host=:^www.apple.com
add dst-host=:^www.airport.us
add dst-host=:^www.itools.info
add dst-host=:^www.appleiphonecell.com
add dst-host=:^captive.apple.com
add dst-host=:^www.thinkdifferent.us
add dst-host=:^www.ibook.info
ขั้งตอนที่ 1.เปิด terminal มา
หลังจากที่เราวาง Script ไปแล้ว ก็ขั้นอย่างมในรูป เป็นอันเสร็จสิ้น 

How to backup and transfer a Proxmox


How to backup and transfer a Proxmox VM to another Proxmox Node


Moving proxmox virtual machines between different servers became very easy with recent proxmox updates. You can use proxmox web GUI or command line interface to create a proxmox virtual machine backup and than move to a remove server. In this article we will see how to backup and transfer a proxmox vm to another proxmox node, both using GUI and command line.

Step 1: Enable your disk to store backups

Normally your hardisk is enabled to be used for:
  • Disk Image
  • Iso Image
  • Container Template
  • Container

That means currently you can not store your virtual machine backup on your hardisk, so you need to make sure that your hard disk can store VZDump Backup File (file that is created after we initiate a virtual machine backup). Please follow the instruction in the image below:
enable-proxmox-to-store-backups
  1. Click on Data Center
  2. Click on storage to list your server storage mediums.
  3. From list select the storage medium on which you need to store backups, we have only one so we selected it from the list.
  4. Once selected than click on Edit.
  5. You will than see that pop-up box that is currently displaced on the screen, from ‘Content’ drop down you can see that all other selections are highlighted blue, make sure VZDump Backup file is also highlighted in blue and click OK to save your changes.
Now your storage medium is ready to store backups.

Step 2: Create Backup

Their are two ways you can create backups, from GUI and command line as well, we will first discuss the command line version because its very easy.

Create backup from command line

Login to your server ssh and run the following command:
It will than take some time for backup to complete, and progress will be displayed on the terminal. It will look something like this.
backup-completed

Create backup from Proxmox GUI

backup-from-gui
  1. Select your virtual machine from left side bar.
  2. Click on Backup.
  3. Click on Backup now
  4. From compression drop down menu select none, if you select the compression it will put the compression over head to the cpu, but backup size will be small.
  5. Finally click Backup.
After that your backup will be in /var/lib/vz/dump folder of the server.

Step 3: Move backup file via scp

Once the backup is completed you can simply scp it to the remote server, please note that your backup file will be named something like this “vzdump-qemu-122-2016_09_13-14_12_32.vma”.
To scp this file to the remote server use the command:
In the command above please replace “vzdump-qemu-122-2016_09_13-14_12_32.vma” -> with your actual backup file name. It will take some time depending upon server network speed at both ends.

Step 4: Restore the backup

Final step is to restore the backup, you can restore backup via command line or GUI.

Restore backup from command line

Restoring backup files are pretty easy through command line:
qmrestore is the command to restore VM, next is the virtual machine name “vzdump-qemu-122-2016_09_13-14_12_32.vma” and the last argument is the VM id (500), you can choose any VM ID that is not being used earlier.

Restore backup from Proxmox GUI


backup-via-gui
  1. Select local storage (normally here the transferred backup will be stored)
  2. Select “Content”.
  3. You will see the list of backups, select the one you just transferred.
  4. Once the backup is selected click Restore.
  5. Input the VM ID:500, or any other ID you want to give to the restored VM.
  6. Finally click Restore.
It will take some time and your VM will be restored to the VM ID you gave at step 5. That’s all to transfer virtual machine from one promox node to another, you can choose either the GUI or command line version but command line version have less head ache.