Sunday, May 15, 2016

Home Lab - Cisco & MikroTik

I would like to share with you my experience of building a network home lab. If you think about to build your own network home lab some of this tips can be useful for you. At the beginning i want to discuss about why to do it and what is the goal of my lab. Even if you have other goal some basic concepts will stay the same.

The first assumption is to do it cheaply. If you live in country where GDP is not the biggest you want to build lab but don't spend all money for it ;)
The second assumption is to have switching, routing and WiFi in lab. Switching give you Cisco devices, routing you have in MikroTik (or Cisco) and WiFi in MikroTik. From my perspective it is the best combination and I will explain why.

When I had chosen Cisco switch I didn't want pass the exam certificate for CCNA or another. I'm just need a professional management switch. That is the reason why I buy End-of-life devices. My choice is Cisco Catalyst 2950 and Cisco Catalyst 3550. The first is switching only device (L2 only), the second switch is combination switching and routing (L2+L3).

Cisco 2950 is great switch, it have all what probably you will need. It have not large size like on switch, low power consumption and it is be quiet. And of course it's cheap today (2016). Another switch Cisco 3550 made a bad first impression for me, is big, noisy and it costs two times more than 2950. But, when I tested it I change the mind. Now it is my favorite switch, but in beginning I have big problem with it. When I enable routing it's working less then one minute and stop working. Upgrade system for highest available version resolved this problem.
So first things which you should do is upgrade all Cisco switch, but here is the next problem. Usually this switch from auctions is send without any cable. So you to have need own power cable and console cable. About console cable, it have two connector, RJ-45 to switch and DB9 to computer (serial port). If you don't have serial port in your computer you need also to have serial port to USB adapter. And finally you can use and upgrade your Cisco switch ;)

Another bad things about this switch is that it's very old and yet not support auto-negotiation (Auto-MDI/MDIX). The result is that, if you want connect two switch together via Ethernet cable you need crossover cable. Yes, and this moment I finish the bad news about Cisco switch 2950 and 3550, it's time for good news :)

I have three Cisco switch in my lab (two 3550 and one 2950), I think it's enough to test of switching (e.g. STP). Now I little describe the 3550 switch. As I had said earlier 3550 offers routing. 2950 can have only one IP address mainly to management, but 3550 can have many IP address. Each port can by used of two mode, routable (L3) and not routable (L2). But you can set L2 port with and without IP address, in result you get three combinations: port L3 (routing), L2+L3 (VLAN + IP) and L2 (VLAN without IP). If you use last combination you can simulate many switches in one 3550 switch. In fact one 3550 switch allows you to use one switch as one router and many switches. That its great.
And I will be forgot, 3550 is selling with two version SMI and EMI. The SMI version don't have all dynamic routing protocol, EMI version have got, but cost double than SMI version of devices. The next great good news is that in the SMI version you can upload EMI image without any technical problem.

Time to describe second type of device which is MikroTik. First of, why MikroTik? Two reasons. The first it's big configuring possibility and CLI interface. The second it's new model named MikroTik hAP lite. It is designed to home use and it's cost is low. In my country in 2016 year one new device of this model cost the same as one Cisco 2950 switch. MikroTik hAP lite has the same version operating system as MikroTik RouterBoard, it has only less powerful equipment (CPU, RAM, etc.). I've three this devices and I'm very happy with them. This MikroTik router with Cisco switch 3550 you can use at the same time as WAN router and as LAN AP, is sufficient that you divide ether-* ports in MikroTik. Generally I think Cisco switch and MikroTik router is a great combination.

The below presents schematic of network in my home lab. With this equipments and computers with Linux system I can simulate any type of Linux service in network (WAN, LAN, WLAN).


And how its looks.





Wednesday, May 11, 2016

GNU/Linux - maxload in fight with overload

Your server is too busy?
You have problem with overload?
You want use CPU resource more effective?

If your answer is YES, maybe you are interested maxload. maxload allow you to run a very intensive task which can be paused and protects your server from overload.

Suppose your Linux server consumes 40% of CPU resource. So you have reserve of 60%. You want use from it but you worry about overload because you don't have control over how much your task will use of CPU resource. maxload resolves this problem and give you possibility to use your CPU say in 99%.

Example
You have very large folder and you must create a backup for this files. This is a very intensive task for CPU and disk. So you create a script like below.

cat backup.sh
#!/bin/bash
tar -cjpf /root/backup/site_file.tar.bz2 /var/www/html/example.com/public_html

Next what you do is run it via maxload and set correct border value for maxload. Suppose your server has 4 CPU cores visible in operating system. So if you want use ~90% of CPU you must set max border on 3.6.

maxload 3.6 /root/backup/backup.sh

More about maxload you can read in GitHub.