Tip: Detect Network Connectivity in Bash
There are times that we are required to check hundreds of servers for network connectivity, and what command comes first in mind when testing network – ping. To help out other system and network administrators out there, here is a quick bash script to ping servers.
#!/bin/bash
SERVERS=server.txt
for i in $(cat $SERVERS)
do
ping -c2 $i > /dev/null
if [ $? -ne 0 ]
then
echo "$i is DOWN"
else
echo "$i is UP"
fi
sleep 3
done
Tip: Can Download Torrents But Cannot Browse
I have recently purchased a new home office router that connects two desktops and one laptop by wireless connection. Back at the store, I made my mind to purchase Linksys WRT54G over D-Link (I forgot the model) because there are a lot of good feedbacks on Linksys.
Everything was good the first two weeks we were using the router. The signal strength is good and my laptop can get decent W-Fi signal anywhere inside. Then the network became rather choppy, pings are intermittent, and worst, one desktop (particularly my desktop PC) cannot browse.
The weird thing I was able to download stuff using torrent, my Pidgin can sign in to my accounts on Yahoo and MSN Messenger and streaming video and music works. Everything works, except for the browser. I blamed the Linksys for this and contacted the support thrice, and I was given a lot of configurations that should be done in the router settings, none of which solved my problem.
Googling around got me some help and apparently, this weird symptoms are caused by the traffic from torrent downloads. To fix this, these settings must be done on the torrent client:
1. Reduce the download and upload speed of torrent client. Since I use the lightweight uTorrent Client, I can simply do this by right-clicking the uTorrent taskbar and selecting the download speed that I want. The procedure could be different depending on your client.
2. Disable DHT. DHT stands for Distributed Hash Tables and disabling this in torrent client effectively solved my problem with browsing. Again in uTorrent, this can be done by pressing CTRL+P to open the Preferences window and selecting the BitTorrent tab. Uncheck the DHT selections and click OK to save the new settings. Restarting the client helps too.
I did these two steps and this solved the issue of not being able to browse the Internet while downloading torrents.
Tip: Prevent SSH Session from Disconnecting
The network connection at office keeps my SSH session from running smoothly. Well, it means I keep on being disconnected from the server when my SSH session turns idle for a certain period of time. It gets annoying especially if I am in the middle of a script running silently.
One alternative I have written before here is using screen command or by editing the SSH config file to prevent SSH from disconnecting its connection.
The process is very simple: your SSH session consistently sends packets over the connection to let the remote computer know that the session is still active and there is no need for termination. This is what they call Keep Alive packets. For me, it means Keep My Sanity packets.
Anyway here is what you need to do. Edit your ssh_config file, usually in /etc/ssh/ directory:
# vi /etc/ssh/ssh_config
And put this line in the file:
ServerAliveInterval 60
Save and exit.
Open the ~/.ssh/config file (or create it if not present) and put this line in it:
Host *
ServerAliveInterval 60
Don’t forget the indent at the second line. Save and exit.
Lastly, reload your new SSH config file by doing:
# /etc/init.d/sshd reload
This should do the trick of fooling the remote server into thinking that your SSH connection is active, even if it is not.
Did this tip worked for you? Let me know in the comments section.
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- wayne donahue on Cebu Pacific Airlines is Evil!
- smeaferrepove on Howto: Install yum On RHEL 4
- Anidich1 on Tip: Add User and Generate Password Script
- Tom S on Cebu Pacific Sucks
- kadersardar on PinoyTux Spreads Some CommentLuv








