« Posts under Linux

Linux rocksolid…

Today someone remember me that we had an antispam server...I really don't rember when we installed, because  since his  installation I never had any problems.

I was curious to know it's uptime... so...

 

[root@galactica ~]# uptime
15:21:43 up 1297 days, 21:16,  2 users,  load average: 0.08, 0.03, 0.01

Yes, 1297 days without reboot (thank you UPS)

this is a Centos 5.5 with postfix+postgrey+clamav+don'trememberwhatelse machine.

java.net.ConnectException: network is unreachable

Under Debian (and I think other distros) if you receive this error on commandline when running java applications,

you can solve it simply setting this kernel parameter will solve the problem

 

sysctl net.ipv6.bindv6only=0

Remotely Reboot Netgear MBRN3000

I made this script to remotely restart our MBRN3000 - Netgear; because there's no way to schedule this directly on the router.
I need to restart because randomly this UMTS router disconnect from the internet using the key and there's nothing  to do  to have the connection up again, except to poweroff the router.

I named the script rebootUMTS.sh and placed in /opt/

this is the code:

#!/bin/sh
wget -q --post-data "button=reboot" http://USERNAME:PASSWORD@172.18.0.2/reboot.cgi
echo `date` " - Restart router" >> /opt/restart.log

and in crontab I've schedule to run every days at 7:00AM 1:00PM 8:PM

*  7,13,20	*	*	*	/opt/rebootUMTS.sh

WordPress redirect

My friend Francesco (www.flussiliberi.it) was hosted on a free service without having a domain ,so, after buying a domain name and space, ask me a way to redirect all vistors that point direct to a post or page in the old WordPress blog to the corresponding page on new site.

I don't know if exist a plugin, but with a few php lines it's possible:

  1.  
  2. <?php
  3. $url="http://www.hacksandmore.com";
  4. if (($_GET["p"] === null) and ($_GET["page_id"] === null) and ($_GET["feed"]=== null) and ($_GET["cat"]=== null)) {
  5. $url=$url;
  6. }
  7. else
  8. {
  9. if(isset($_GET["cat"])) $url=$url."/?cat=".$_GET["cat"];
  10. if(isset($_GET["feed"])) $url=$url."/?feed=".$_GET["feed"];
  11. if(isset($_GET["p"])) $url=$url."/?p=".$_GET["p"];
  12. if(isset($_GET["page_id"])) $url=$url."/?page_id=".$_GET["page_id"];
  13. }
  14. <fieldset>
  15. <h1>Site transferred,
  16. redirect in a few seconds...</h1>
  17. <h3>WP redirect by: Umberto Bernardi
  18. <a href="http://www.hacksandmore.com">www.hacksandmore.com</a></h3>
  19. </fieldset>
  20. <script type="text/javascript"><!--mce:0--></script>
  21. ";
  22. ?>
  23.  

You can download the script in the right panel in Downloads section

NFS VMware Datastore with QNAP

The new Qnap nas has also NFS service onboard, so I want try to use it as "addon datastore" for my VMware infrastructure.
I know poor performance but I'll use it to keep CD/DVD images, test virtual machines an why not, backup.

First of all we have to check if our esx hosts can reach the NAS, I mean the VMKERNEL, not the management, so ssh into your ESX and try with

root@esxhost# vmkping your.nas.ip

If you get response you are done, if not you have 2 solutions:

  • put your nas in the vmkernel's network
  • add another vmkernel

I've added another vmkernel, because we use the first for Vmotion and I want keep this separate.

So, open VI client, from inventory view choose "Hosts and Clusters" select the first Esx host and go to "configuration tab.", select "Networking" then "Add Networking".

Using the Wizard, select VMkernel and click Next. According with your network configuration, select the VSwitch that can communicate with your NAS

Give a name, IP Address and netmask (on the same netwok of NAS) to the new interface

Click Next and finish.

Try to "vmkping" and you should see response.

Now repeat these steps for all ESX hosts you have

Instruction From QNAP to use NFS on with VMware are not correct, because ESX is able to use NFS only over TCP; unforntunatley Qnap nas use NFS over UDP.

So we have to "force" the QNAP to use TCP instead of UDP...
In the configuration page on NAS there's no way to change this; so we have to connect in SSH and edit this file:
/etc/init.d/nfs

the line to change is #132

NO_V4="-N 4 --no-udp"

Reload the NFS service

/etc/initd/nfs restart

Now through the web management we can set permission to the share we want use

I permit full access from both esx hosts to this share

So, open VI client, from inventory view choose "Hosts and Clusters" select the first Esx host and go to "configuration tab.", select "Storage" then "Add Storage".

Follow the wizard  for configuration:

Select "Network File System"

Fill with ip address or name of your NAS, in the Path field put the name of the share you previously defined on the NAS

Click Next and finish.

Repeat this step with same data for all ESX hosts and you are done.

N.B.
this how to require you know what are you doing.
I'm not responsible if you destroy your production machine following my instruction.