Saturday, 17 January 2015

TUTORIAL MIKROTIK


                              TUTORIAL MIKROTIK


  • Mikrotik now widely used by ISPs, hotspot providers, or by the owner of thecafe. Mikrotik OS router makes the computer into a reliable network that is equippedwith various features and tools, for both wired and wireless. In this tutorial the author presents a discussion and a simple and simpleinstructions on configuring the proxy for certain purposes and the public is typicallycollected in server / router cafe as well as other tissues, such configuration forexample, for server NAT, Bridging, BW management, and MRTG.Mikrotik version I use for this tutorial is MikroTik RouterOS 2.9.27Access MikroTik: 1. via console Mikrotik router board or PC can be accessed directly via the console / shell and remote access using putty (www.putty.nl) 2. via Winbox Mikrotik can also be accessed / remotely using software tools Winbox 3. via web Mikrotik can also be accessed via web / port 80 by using a browser • Naming MikroTik[ropix@IATG-SOLO] > system identity print name: "Mikrotik"[ropix@IATG-SOLO] > system identity editvalue-name: nameEnter the editor type for example I change the name IATG-SOLO:IATG-SOLOC-c quit C-o save&quit C-u undo C-k cut line C-y pasteEdit and then press Clrl-O to save and exit the editor 1
  • 2. If using Winbox, it looks like this: • Changing the name of the interface:[ropix@IATG-SOLO] > /interface printFlags: X - disabled, D - dynamic, R - running # NAME TYPE RX-RATE TX-RATE MTU 0 R ether1 ether 0 0 1500 1 R ether2 ether 0 0 1500[ropix@IATG-SOLO] > /interface edit 0value-name: nameThe value 0 is the value ether1, if you want to replace ethet2 value 0 replaced by 1.Entrance to the editor, for example I replace it with name local:localC-c quit C-o save&quit C-u undo C-k cut line C-y paste Edit and then press Cltr-o to save and exit the editor, Do the same for interfaces ether2, so that if seen again will appear like this:[ropix@IATG-SOLO] > /interface printFlags: X - disabled, D - dynamic, R - running # NAME TYPE RX-RATE TX-RATE MTU 0 R local ether 0 0 1500 1 R public ether 0 0 1500 2
  • 3. Via Winbox: Select the menu interface, click the name of the interface that wants to be edited, so itappears the edit window interface. • Setting IP Address:[ropix@IATG-SOLO] > /ip address addaddress: 192.168.1.1/24interface: local[ropix@IATG-SOLO] > /ip address printFlags: X - disabled, I - invalid, D - dynamic # ADDRESS NETWORK BROADCAST INTERFACE 0 192.168.0.254/24 192.168.0.0 192.168.0.255 local Enter the IP address value in the column address and netmask, enter the name of theinterface that wants to be given an IP address. For public interface Interface 2,namely, the same way as above, so that if seen again will be 2interfaces:[ropix@IATG-SOLO] > /ip address printFlags: X - disabled, I - invalid, D - dynamic # ADDRESS NETWORK BROADCAST INTERFACE 0 192.168.0.254/24 192.168.0.0 192.168.0.255 local 1 202.51.192.42/29 202.51.192.40 202.51.192.47 public 3
  • 4. Via Winbox: • Make Mikrotik NAT Network Address Translation or more commonly referred to as NAT is a method toconnect more than one computer to the Internet network using a single IP address.Number of use of this method due to limited availability of IP addresses, the need forsecurity , and the ease and flexibility in network administration. Currently, the widely used IP protocol is IP version 4 (IPv4). With a length of theaddress 4 bytes means that there are 2 to the power 32 = 4,294,967,296 IP addressesavailable. This amount is theoretically the number of computers that can directlyconnect to the internet. Because of this limitation most of the ISPs (Internet ServiceProvider) will only allocate one address for one user and this address is dynamic,meaning that a given IP address will be different every time the user connects to theInternet. This will make it difficult for businesses to lower middle class. On the onehand they need more computers are connected to the Internet, but on the other handonly one IP address which means there is only one computer that can connect to theinternet. This can be overcome by using NAT. By NAT gateways that run on onecomputer, one IP address can be shared with several other computer and they canconnect to the internet simultaneously. Suppose we want to hide the local network / LAN 192.168.0.0/24 202.51.192.42behind one IP address provided by ISP, which we use is a feature of Mikrotik sourcenetwork address translation (masquerading). Masquerading changes the data packetsfrom the IP address and port from the network 192.168.0.0/24 to 202.51.192.42henceforth be forwarded to the global Internet network. 4
  • 5. To use masquerading, source NAT rule with action masquerade should be added tothe firewall configuration:[ropix@IATG-SOLO] > /ip firewall nat add chain=srcnataction=masquerade out-interface=publicIf using Winbox, will look like this: • As a transparent web proxy mikrotik One function is to store the proxy cache. If a LAN uses a proxy to connect to theInternet, it is done by the browser when a user accesses a web server URL is to takethese requests on a proxy server. Whereas if the data is not contained in the proxyserver then proxies to pick up directly from the web server. Then the request is stored 5
  • 6. in the cache proxy. Furthermore, if there are clients who make requests to the sameURL , it will be taken from the cache. This will make access to the Internet faster. How to ensure that each user accessing the Internet through a web proxy that we haveenabled? To this we can apply the transparent proxy. With transparent proxy, everybrowser on computers that use this gateway automatically goes through a proxy.Enabling web proxy in mikrotik fiture:[ropix@IATG-SOLO] > /ip proxy set enabled=yes[ropix@IATG-SOLO] > /ip web-proxy setcache-administrator= ropix.fauzi@infoasia.net[ropix@IATG-SOLO] > /ip web-proxy printenabled: yessrc-address: 0.0.0.0port: 3128hostname: "IATG-SOLO"transparent-proxy: yesparent-proxy: 0.0.0.0:0cache-administrator: "ropix.fauzi@infoasia.net"max-object-size: 8192KiBcache-drive: systemmax-cache-size: unlimitedmax-ram-cache-size: unlimitedstatus: runningreserved-for-cache: 4733952KiBreserved-for-ram-cache: 2048KiB Make a rule for transparent proxy on the firewall NAT, precisely there masqueradingunder the rule for NAT:[ropix@IATG-SOLO] > /ip firewall nat add chain=dstnat in-interface=local src-address=192.168.0.0/24 protocol=tcp dst-port=80action=redirect to-ports=3128[ropix@IATG-SOLO] > /ip firewall nat printFlags: X - disabled, I - invalid, D - dynamic 0 chain=srcnat out-interface=public action=masquerade 1 chain=dstnat in-interface=local src-address=192.168.0.0/24protocol=tcp dst-port=80 action=redirect to-ports=3128In Winbox:1. Enable web proxy on the menu IP> Proxy> Access> Settings (check box enabled) 6
  • 7. 2. Parameter settings on the IP menu> Web Proxy> Access Settings> General 7
  • 8. 3. Make a rule for transparent proxy on the menu IP> Firewall> NAT • Transparent proxy with proxy servers separate / independent MikroTik Web Proxy built in according to my observations not so good compared tothe squid proxy in Linux, squid in Linux has more flexibility to be modified anddiconfigure, eg for delay-pool feature and ACL lists that include files, not in the proxyseries 2.9.x.Usually most people prefer to create their own proxy servers, with PC Linux /FreeBSD and live directing all clients to the PC.Topology PC proxy can be in a local network or using public ip.Configuration almost similar to the transparent proxy, the difference is in the actionNAT rule is as follows: 8
  • 9. In the above example 192.168.0.100 is the IP proxy server port 8080 • Mikrotik as a bandwidth limiter Mikrotik can also be used for bandwidth limiter (queue). To control the data rateallocation mechanism. In general there are 2 types of bandwidth management at the proxy, the simple queueand queue trees. Please use one only. The next tutorial mikrotik all settings using Winbox, because it is more user friendlyand efficient.Simple queue: For example we will limit the bandwidth of the client with ip 192.168.0.3 that is forupstream and downstream 128kbps 64kbpsSettings on the menu Queues> Simple QueuesQueue treeClick the ip> firewall> magle 9
  • 10. Make a rule (click the + red) with the following parameters:On the General tab:Chain = forward,Src.address = 192.168.0.3 (or ip who want the limit)On the Action tab:Action = mark-connection, New connection-mark = client3 con (or the name of the mark we created adistinguished conection)Click Apply and OK 10
  • 11. Create another rule with the following parameters:On the General tab: chain = forward,Connection mark = client3-con (choose from dropdown menu)On the Action tab:Action = mark-packet,New pcket Mark = client3 (or the name of the packet we created a distinguishedmark)Click Apply and OKClick the Queues> Queues Tree 11
  • 12. Make a rule (click the + red) with the following parameters:On the General tab:Name = client3-in (eg),Parent = public (which is the direction of outgoing interface),Mark = client3 Package (choose from the dropdown, just that we make to magle)Queue Type = default,Priority = 8,Max limit = 64k (for setting the bandwidth max download)Click aplly and Ok 12
  • 13. Create another rule with the following parameters:On the General tab:Name = client3-up (eg),Parent = local (as an interface into which direction),Mark = client3 Package (choose from the dropdown, just that we make to magle)Queue Type = default,Priority = 8,Max limit = 64k (for setting max upload bandwidth)Click aplly and OkMikrotik as Bridging Bridge is a way to connect two separate network segments together in a protocolitself. Packages that are forwarded based on Ethernet addresses, not IP addresses(such as routers). Because the packet forwarding done at Layer 2, all protocols can bevia a bridge. So the analogy is like this, you have a local network 192.168.0.0/24 gateway to anADSL modem which also as a router with a local ip 192.168.0.254 and public ip222.124.21.26. You want to create a proxy server and proxy as a BW management for all clients.Well want to put the location for the PC mikrotik? Among the hub / switch andgateway / modem? Do not be like him as a NAT and we have to add 1 block ioprivate again different from the gateway modem? The solution set as a bridging proxy, so seolah2 he only bridge between UTP cableonly. Topology as follows:Internet----------Moderm/router-----------Mikrotik--------Switch/Hub-----ClientSetting bridging using Winbox1. Add a bridge interface Click the Interface menu and then click the + sign to add a red color interface, selectthe Bridge 13
  • 14. to name bridge interface, eg, we named bridge12. adding ether interface on the local and public interfaceClick the IP> Bridge> Ports, then click the + sign to add a new rule:Make 2 rules, to local and public interface.3. Giving IP address to bridge interface Click the IP menu and then click the + sign to add an interface IP, eg 192.168.0.100,select bridge1 interface (or the name of the bridge interface that we created earlier) 14
  • 15. By giving the IP address on bridge interface, the proxy can be either remote from thenetwork which is connected to a local interface or the public.Mikrotik as MRTG / Graphing Graphing is a tool in mokrotik enabled to monitor changes in the parameters at anytime. Changes that change the form of graphs uptodate and can be accessed using abrowser.Graphing can display the information in the form:* Resource usage (CPU, Memory and Disk usage)* Traffic passing through the interfaces* Traffic through simple queuesActivating the function grappingClick the Tools menu> Graphing> Resource RulesIs to enable graphing for Mikrotik resource usage. While allow address is anywhereIP that can access these charts, 0.0.0.0 / 0 for all ip address.Click the Tools menu> Graphing> Interface Rules Is to enable graphing for monitoring traffic passing through the interface, pleaseselect which interface you want monitored, or select "all" for all. 15
  • 16. Graphing consists of two parts, first to collect information / data that both show in aweb format. To access the graphics, type the URL with the format http://[Router_IP_address] / graphs / and choose from the menus there, where you want todisplay graphics.Sample results graph for traffic public interface: Similarly, the authors convey a little tutorial for just sharing the knowledge orsimplify for easy understanding of the tutorials that are already available on theofficial site mikrotik.

No comments:

Post a Comment