How to limit MySQL port access to specific network

MySQL service port are not meant to be accessible to the outside world as it would become a security concern to the administrator.

Although MySQL server (mysqld) by itself has a built-in mechanism to deny access from unauthorized ip-address, it still does not protect it from being overwhelmed by multiple malicious requests or buffer overflow attack directed to the server.

One of the solution is to limit the MySQL port access to trusted network using iptables

This assume your trusted network has the address within the range of 192.168.1.1-192.168.1.254


iptables -A INPUT -i eth0 -p tcp -s 192.168.1.0/24 --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT

MySQL server (mysqld) uses port 3306.

Note: Always assume the internet as the untrusted network!

How to: Quick and Dirty Web Server Load Balancing with IPTables in Linux

Load balancing is a method to distribute workload across multiple computer over a network. The purpose of load balance in web server is to avoid one web server from being overwhelmed by requests which eventually leads the machine to come down to a crawling halt.

Assuming that you have 3 web server to assign the load to each with this IP Address:
10.20.20.1
10.20.20.2
10.20.20.3

You can drive the traffic to each of this on every third packet with this iptables rules:

iptables -A PREROUTING -i eth0 -p tcp --dport 80 -m state --state NEW -m nth --counter 0 --every 3 --packet 0 -j DNAT --to-destination 10.20.20.1:80

iptables -A PREROUTING -i eth0 -p tcp --dport 80 -m state --state NEW -m nth --counter 0 --every 3 --packet 1 -j DNAT --to-destination 10.20.20.2:80

iptables -A PREROUTING -i eth0 -p tcp --dport 80 -m state --state NEW -m nth --counter 0 --every 3 --packet 2 -j DNAT --to-destination 10.20.20.3:80

This will ensure that every 3rd packet of the request will be properly distributed among the three servers to balance the load. Note that this is only useful in simple website which serves static content or for a download servers that serve large files over the internet (CD or DVD iso downloading)

How to solve Apache – Could not reliably determine the server’s fully qualified name – error in Ubuntu

Apache2 web server will almost always display this information message :
"Could not reliably determine the server's fully qualified name"
when it is first started in Ubuntu and Debian server.

The reason behind this message is because the web server fails to find the suitable domain name in the system.

How to remove the message
First, you need to edit “/etc/hosts” file and put your server name of choice in the file. For example:

127.0.0.1 server.mylocal

Then you need to add “ServerName” directive in the “/etc/apache2/apache2.conf” file.

ServerName server.mylocal

Finally, restart the web server for the changes to take effect. You will notice that the information message is gone now.

$ sudo service apache2 restart

How to mine Bitcoin in Ubuntu using OpenCL and Bitcoinminer.py

Bitcoin is a form of decentralize digital currency, so unlike other digital currency services (like e-gold), bitcoin is not susceptible to be frozen, seized or invalidated. Bitcoin can be transfered transfered directly from person to person directly without intermediaries.

Bitcoin are generated over the internet by application called bitcoin miners using a set of algorithm to ensure that the number of generated bitcoin is within predictable and limited range. Though with the numbers of bitcoin in circulation today means that it would require significant processing power to generate bitcoins, it doesn’t stop anybody who are willing to try and mine them.

For a brief introduction to Bitcoin, please watch :

Bitcoin Miner on Ubuntu ?
Enter OpenCL and Bitcoinminer.py which allows bitcoin to be mined using a much more efficient GPU power (certain models of Nvidia and ATI graphic cards only, with appropriate drivers).

Step 1: To install the miner, you need to “install python-pyopencl subversion.

Step 2: Then you need to use subversion to obtain python-jsonrpc, by running:

svn checkout http://svn.json-rpc.org/trunk/python-jsonrpc
cd python-jsonrpc/
sudo python setup.py install

Step 3: Then you need to generate bitcoin.conf file:

cd ..
mkdir .bitcoin
echo "rpcuser=username" > .bitcoin/bitcoin.conf
echo "rpcpassword=password" >> .bitcoin/bitcoin.conf

Step 4: After that, download BitcoinMiner files

wget --no-check-certificate https://github.com/m0mchil/poclbm/raw/master/BitcoinMiner.cl
wget --no-check-certificate https://github.com/m0mchil/poclbm/raw/master/BitcoinMiner.py
wget --no-check-certificate https://github.com/m0mchil/poclbm/raw/master/poclbm.py

Step 5: Download bitcoin server for linux

wget http://iweb.dl.sourceforge.net/project/bitcoin/Bitcoin/bitcoin-0.3.19/bitcoin-0.3.19-linux.tar.gz
tar xvf bitcoin-0.3.19-linux.tar.gz
~/bitcoin-0.3.19/bin/64/bitcoin -server&

Step 6: Then finally, running the miner

python poclbm.py -d 0 --user username --pass password

The parameter -d 0 denotes that the miner will use GPU #1 for its bitcoin mining generation, increment it to -d 1 for GPU #2 and so forth. Change the “password” and “username” parameter from Step 3 and Step 6 appropriately to keep people from reaping the fruits (read: steal bitcoins) of your mining operation.

For more information about mining bitcoins and about Bitcoin in general, please visit : WeUseCoins website

Setup Free Web Proxy Service with Glype (PHP Script)

Glype is a web-based proxy script written in PHP which allows user to browse the internet anonymously using a web-based user-interface. Website operator can easily setup web-proxy without the need to go through complicated installation procedures.

Glype Proxy Service

Among the feature of Glype Proxy Script are:

  • No Installation – Just upload and done!
  • Javascript support – Allows website to keep their javascript functionality
  • Blacklist by IP – Admin can easily block users by IP address range
  • Virtual browser – allow user to change user-agent and
  • Server-side caching – Reduces bandwidth and server loads for frequently accessed website

Download Glype from its official website