Monday, March 28, 2016

MikroTik - How To Block Facebook

MikroTik - How To Block Facebook

Block Facebook Webpage Base Content String:

IP --> Firewall --> Firewall Rule --> New Firewall Rule








MikroTik - Allow Remote Desktop From External

Allow Remote Desktop From External

IP --> Firewall --> NAT

Create new NAT
Tab,   General 
Tab,  Action

Done,

Sunday, March 27, 2016

MikroTik Fail Over Dual WAN

MikroTik Fail Over Dual WAN

This is a Lab Scenario, We have 2 IP address with 2 Gateway to Internet as above.
Here We go:
* 8.8.8.8 = Public Google DNS
* 221.132.112.8 = TW DNS (PK)

 1.    Login
Login with user (admin) and (no password)

2. Set New Password
psswor
3.  Set Hostname
system  identity set name=HQ-MKT6.30
4. Set IP, DNS , Gateway and NAT
ETHER1
interface Ethernet set name=ISP1 ether1
ip address add address=124.248.161.61/29 disabled=no interface=ISP1
ip dns set servers=8.8.8.8 allow-remote-request=yes
ip route add gateway=124.248.161.62 check-gateway=ping
ip firewall nat add action=masquerade chain=srcnat disabled=no out-interface=ISP1

ETHER2
interface Ethernet set name=LAN172 ether2
ip address add address=172.16.5.254/24 disabled=no interface=LAN172

ETHER3
interface Ethernet set name=ISP2 ether3
ip address add address=124.248.160.209/28 disabled=no interface=ISP2
ip dns set servers=221.132.112.8 allow-remote-request=yes
ip route add gateway=124.248.160.222 check-gateway=ping
ip firewall nat add action=masquerade chain=srcnat disabled=no out-interface=ISP2

5. Configure Load Balance
ip route add dst-address=8.8.8.8 gateway=124.248.161.62 scope=10
ip route add dst-address=221.132.112.8 gateway=124.248.160.222 scope=10
ip route add distance=1 gateway=8.8.8.8 check-gateway=ping
ip route add distance=2 gateway=221.132.112.8 check-gateway=ping                                           

That All, Done.

Wednesday, March 23, 2016

MikroTik VPN site-to-site

MikroTik VPN site-to-site

This is the IP diagram, and doing on only the HQ-MikroTik guideline,
for the BR01-MikroTik just doing the same, just revers IP. 

 Test ping from HQ to Branch, 

 Test ping from Branch to HQ, 

Done, ;)

Monday, February 22, 2016

Graph Base Policy

Graph Base Policy

First need to get these:
- On Router allow your server IP to check that Router
- Info on Router: router-01#show policy-map interface tenGigabitEthernet 0/0/1.298 output

Step1:  Get ifindex for the cl-ggc. (The fastest way is get this index from Cacti)
index: 44

Step2: Get the cbQosIfndex for corresponding IfIndex in router
snmpwalk -v 2c -cPuBlic_SNMP router-01 1.3.6.1.4.1.9.9.166.1.1.1.1.4 | grep -i 44

SNMPv2-SMI::enterprises.9.9.166.1.1.1.1.4.704 = INTEGER: 44 in 704
SNMPv2-SMI::enterprises.9.9.166.1.1.1.1.4.706 = INTEGER: 44 out 706

Step3: Below is the mib to get the names of class-map configured on the router
snmpwalk -v2c -c PuBlic_SNMP router-01 1.3.6.1.4.1.9.9.166.1.7.1.1.1 |egrep -i cl-ggc
SNMPv2-SMI::enterprises.9.9.166.1.7.1.1.1.366370270 = STRING: "cl-ggc"

Step4: cbQosConfigIndex can be for the class-map can be fetch from following mib
snmpwalk -v2c -c PuBlic_SNMP router-01 1.3.6.1.4.1.9.9.166.1.5.1.1.2 | egrep -i 'Gauge32: 366370270'
SNMPv2-SMI::enterprises.9.9.166.1.5.1.1.2.704.65536 = Gauge32: 366370270
SNMPv2-SMI::enterprises.9.9.166.1.5.1.1.2.706.65536 = Gauge32: 366370270

So:
in: TenGi 0/0/1.298 - customer - youtube - in
.1.3.6.1.4.1.9.9.166.1.15.1.1.11.704.65536

out: TenGi 0/0/1.298 - customer - youtube - out
.1.3.6.1.4.1.9.9.166.1.15.1.1.11.706.65536

On Cacti need to add these policy in and out, and create the graph policy and select those policy in and out.

Saturday, February 20, 2016

Ubuntu Repository - 14.10

Ubuntu Repository - 14.10

Some your Ubuntu repo was broken, error or can not install any packages, 
Comment your own repo and add these line and run 
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

Friday, February 19, 2016

Script Check WiFi Users Connected

Script Check WiFi Users Connected

#!/bin/bash
# By: Vannak Ken
# This script going to check on the connected user on wifi in the wifi listed.
TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S`
MAILTO="ken.vannakk@gmail.com vannak.ken@example.com"
for i in `cat /opt/scripts/wifi/all-wifi.txt`;
    do
        # ------------------------------- NUMBER USERS CONNECTED ------------------------------------------ #
        USERCONNECTED=`snmpwalk $i -v 1 -c PuBlic_SNMP-RO enterprises.41112.1.4.5.1.15.1 |awk '{print $4}'`
        echo "$i : $USERCONNECTED" >> /opt/scripts/wifi/wifi-report-$TIMESTAMP.txt
        #USERS CONNECT MORE THE 20 SEND EMAIL
        USERMAX=20
        if [[ "$USERCONNECTED" -ge "$USERMAX" ]];
                then
                        echo "$i Users More Than 20." > /opt/scripts/wifi/wifi-20users-or-more.txt
                        mail -s "$i Users More Than 20" $MAILTO < /opt/scripts/wifi/wifi-20users-or-more.txt
                else
                        echo "$i Users Less Than 20"
        fi
        # ------------------------------------------------------------------------------------------------- #
        # -------------------------------- CHECK WIFI NO USER OR CAN NOT CONNECTED ------------------------ #
        NOUSER=0
        if [[ "$USERCONNECTED" == "$NOUSER" ]]; then
                       echo "$i No Users connected." > /opt/scripts/wifi/wifi-no-users-connected.txt
                        mail -s "$i No Users connected." $MAILTO < /opt/scripts/wifi/wifi-no-users-connected.txt
                else
                        if [[ -z "$USERCONNECTED" ]] ; then
                                echo "$i Cannot Connected." > /opt/scripts/wifi/wifi-cannot-connected.txt
                                mail -s "$i Cannot Connected" $MAILTO < /opt/scripts/wifi/wifi-cannot-connected.txt
                           else
                                echo "$i Connected normally."
                        fi
        fi
        # ------------------------------------------------------------------------------------------------- #
    done
# Send email with ttached the report
mail -s "Wifi Report - $TIMESTAMP" $MAILTO < /opt/scripts/wifi/wifi-report-$TIMESTAMP.txt
rm -rf /opt/scripts/wifi/wifi-20users-or-more.txt
rm -rf /opt/scripts/wifi/wifi-no-users-connected.txt
rm -rf /opt/scripts/wifi/wifi-cannot-connected.txt
# Remove old report
find /opt/scripts/wifi/ -name "*.txt" -mtime +30 -exec rm -f {} \;