Restart Network in Ubuntu Linux

July 08, 2013
In Ubuntu there was inbuilt command whose job is to network card reconfiguration. Lets see the syntax

jay@server:~$ sudo /etc/init.d/networking restart
****OutPut****
[sudo] password for jay:
 * Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces                                                              
 * Reconfiguring network interfaces...                                                                                                                   ssh stop/waiting
ssh start/running, process 1818
                                                                         [ OK ]

This Ubuntu script will start and stop all network interface (NIC) at once.

Alternative

jay@server:~$ sudo ifconfig eth0 down
 (replace eth0 with your ethernet number)
wait for ethernet down.

jay@server:~$ sudo ifconfig eth0 up
[sudo] password for jay:

Find and replace text in Linux Command

July 08, 2013
Most of you encounter a situation where you need to replace the text in Linux file. Recently  I need to do this in Ubuntu server for changing repo "US"  to "local" repo. Therefore here is the process how to change it.

You can use vi and vim text editor comes with every Linux OS, if your Linux don't have full function text editor then use this link to install it.

In my case I use it for replace international repo to local repo, you can use for any text replacement.

So I use word "US" to replace with "NP", Which is local for me.
Now use the following command to edit repo source

#sudo vi /etc/apt/sources.list


You can see  repo source list file is opened, then just use the following syntax to replace the text: In my case I use "us" and "np" word, please replace these with your desire word.

:%s/us/np/g

or if you need to conformation then you us this command, mean if you don't need to replace whole text.

:%s/us/np/gc

following command can be used for current line only
:s/us/np/g

Understanding STP Ports States

June 19, 2013
Hello! Frens, here is another article about STP, in this article I try to explain switch port status and how we  recognize ports status as well as Root ID and Bridge ID, What MAC address STP take to elect the Root Bridge. Hope this article is useful to understand Spanning Tree Protocol and at last I try to explain why we need RSTP. I'll post another article about RSTP in coming days.

As I already explain in my previous article about STP Root Bridge election, now we can see S1 have lowest MAC address wins the Root Bridge, let’s verified and check the status of the switches ports.
Look at the picture above we can see, from the VLAN001, which have Root ID and Bridge ID, Root ID have all information about the Root Bridge, that mean S2 knows that is the Root Bridge and out port is Fa1/1, which is Root Port and directly connected to the RB. Root Bridge has priority of 32769, MAC is 000D.BD2D.6BD9, and cost is 19 to reach the Root.

Bridge ID is information about the S2, itself, this is what switch2 is. Where normal priority 32768 plus the VLAN number 1, S2 own MAC address is 0030.F24E.C5A1.

Look out to the interface, Fa1/1 which is Root and its status is forwarded, its directly connected to the RB, Fa2/1 is connected to the PC which is not participating to STP and Fa0/1 is connected to S0, this one also on forwarding state.

Let’s look out the S1 and check the status.
From the picture, output of the S1, On Root ID information VLAN001, priority 32769, MAC Address 000D.BD2D.6BD9, This bridge is root, so you can see that Root ID and Bridge ID information is the same because this is the Root Bridge for this network. All of its port is designated and forwarding state. Root always have all its ports in designated none of its port in block state.
Now look at the S0 information, in S0 you can see Fa0/1 is Root and its directly connected and forwarding state. Fa1/1 is in blocking state because it has the highest MAC address and its prevent the loop in the network.
From the topology form the picture, now we are going to change the root, we just make S2 a root bridge, lets see the status of the S2.
Command to change STP root bridge, you can see on above screeshots.
swtich#conf t
switch(config)#spanning-tree vlan 1 root primary
switch(config)#end
switch#show spanning-tree 

All its ports became designated, this bridge is root. After changing state S2 became the root now S0 have worst MAC address, so S0 fa0/1 is on blocking state. Take a look on priority, its change to lower to 24577, which is increment of 4096. This is the basic configuration of Spanning tree.

Now consider this scenario, the primary link is down, how long STP take to bring back secondary link online, how long it take time to change the route? Your phone is ringing; all asking what is going on? Why the link is down, what is going on?
This is happen because STP is created in long time ago, when no one care 30 to 60s downtime in the network, now the situation is change, a second downtime is not expected by the people.

We can analyze cisco switch, whenever you plug your cisco switch, you can see Amber led blinking, this is STP, by default Cisco Switch have STP enable. When its power on, switch is on Listening state for 15s, than its goes 15s for learning then forwarding and if switch goes for Blocking state, it still goes down for 20s, that is because its wait if primary link back online. We have 50s network outage to find out our primary link is down. This is not acceptable for today’s network. That’s why RSTP is handy for today's network.  





Script for mikrotik router

June 13, 2013
Here is some script of Mikrotik router to add IP address and make queue list on top.

Adding such a huge IP Address one by one is very difficult and time consuming task. So here a script to add IP Address in Mikrotik router.

Tested on MT OS verson 5.x

Make sure you already open the MT with Winbox, in my case I already done.
Click on System Menu on the left and choose Script from popup menu, see below


Now on Script list window. click Plus(+), then copy paste below script on source field. Like in picture

:for i from=2 to=51 do={/queue simple add name="192.168.20.$i" target-address="192.168.20.$i/32" max-limit="64000/128000" parent=Night-User time=19h-7h,sun,mon,tue,wed,thu,fri}

(Modified it with our requirement)



To view the queue list, which we have just add Click on Queues on the left pane, you can see look like this.


This Script make your queue list at top of the list. 

/queue simple move [find name=(you-name)] 0