Vmware ESXi NAT Networking

The case: You have multiple virtual machines that you don’t want to expose directly to the internet and you prefer routing them through a single virtual machine. This is also handy if you are short on IPs. Our case is OVH specific and it will give you a guide on how to set things up on OVH weird network topology. Reason why we use ipcop instead of pfsense is because pfsense doesn’t support a 32bit net mask. No matter what i’ve tried i could get it to work with a 32 bit netmask and gateway on separate network. So IpCop was the next best thing and it does the job quite well.

ESXi Configuration:

Login to your Vsphere client and go to Configuration -> Networking.

On Network Access select “Create a vSphere standard switch” without select any vmnic .

Proceed to Connection Settings and name your new nic under “Network Label” . “Vlan ID” select None.

Proceed on creating a new VM including both NICs the one that you just created and the one that connects you to the outside world.

Then move on with standard installation of IPcop. Keep in mind that your RED network will be the one connecting outside and the GREEN one will be your internal nat network. If you are not sure of the network settings while installing proceed and will edit network config later on anyways.

After installation login to the machine and now let’s edit the files needed for proper networking under OVH routers.

vi /var/ipcop/ethernet/settings

DEFAULT_GATEWAY=Dedicated Server IP but end in .254
DNS2=8.8.4.4
DNS1=8.8.8.8
RED_1_NETADDRESS=IP Failover
RED_1_NETMASK=255.255.255.255
RED_1_ADDRESS=IP Failover
RED_1_BROADCAST=IP Failover
GREEN_1_NETADDRESS=192.168.1.0
GREEN_1_NETMASK=255.255.255.0
GREEN_1_ADDRESS=192.168.1.1
GREEN_1_MAC=Your Virtual Mac Address
GREEN_1_DRIVER=pcnet32
GREEN_1_OPTIONS=
GREEN_1_DEV=lan-1
RED_1_MAC=Your Virtual Mac Address
RED_1_DRIVER=pcnet32
RED_1_OPTIONS=
RED_1_DEV=wan-1
RED_1_TYPE=STATIC
ORANGE_COUNT=0
BLUE_COUNT=0
RED_COUNT=1
GREEN_COUNT=1

vi /etc/rc.d/rc.event.local

#!/bin/sh
route add Dedicated Server IP but end in .254 dev wan-1
route add default gw Dedicated Server IP but end in .254

Reboot and you are done! You can now login to the web interface under https://192.168.1.1:8443

Advertisements

#esxi, #ipcop, #nat, #ovh, #pfsense, #virtual-machine, #vmware-2

Android Studio Installation: Error, “failed to find java version for ‘C:\windows\system32\java.exe”

So this is quite simple to solve.

Goto http://www.oracle.com/technetwork/java/javase/downloads/index.html and download the latest jdk for your architecture x32 or x64.

Install as usual and then goto Control Panel -> “Advanced System Settings”

Click on the “Enviroment Variables” and under “System Variables” click “New..”

Then create a new entry with Variable Name: “JAVA_HOME” and Variable Value: “C:\Program Files\Java\jdk1.7.0_21” (this differs according to the version and system).

Save and restart android studio installation and it should identify the correct pat.

#android, #android-studio, #development, #error, #failed, #java

Bash: Script to monitor hard disk health and send an e-mail on error.

Here is a simple script to test for reallocated sector count and report through mail if it finds any.
Reallocated sectors means your disk has sectors where it can’t read/write thus it uses a reserved space to reallocate those sectors.
In general reallocated sectors are bad news for your disk and you should consider a backup and send to warranty.
The script reads the smart value and reports. It should be self explanatory to use it just type ./scriptname.sh nameofthehost. Afterwards set a cron to run daily.
Credits to Thorsten Rhau for the base script.

#!/bin/bash
# This script checks the health of disks

#Define a friendly name for this machine
mname="$1"

#Location to temporary store the error log
logloc="/root/scripts"
#Set default for not sendig mails
sendm="0"

# Disks to check
disks="/dev/sda
/dev/sdb"

# Setting up path
PATH="$PATH:/usr/bin:/usr/sbin"

# variable containing all needed commands
needed_commands="smartctl awk mail"

# Checking if all needed programs are available on system
for command in $needed_commands
do
  if ! hash "$command" > /dev/null 2>&1
  then
    echo "$command not found on system" 1>&2
    exit 1
  fi
done

# Checking disk
for disk in $disks
do
  # Creating a array with results
  declare -a status=(`smartctl -a -d ata $disk | awk '/Reallocated_Sector_Ct/ || /Seek_Error_Rate/ { print $2" "$NF }'`)
  # Checking that we do not have any Reallocated Sectors
  if [ "${status[1]}" -ne 0 ]
  then
    echo "$mname Warning: Disk $disk has errors! ${status[0]} ${status[1]} ${status[2]} ${status[3]}. Following complete smartctl output." >> diskerror.log
    smartctl -a -d ata $disk >> $logloc/diskerror.log
    failed=("${failed[@]}" "$disk")
    sendm="1"
  fi
done

#Send an e-mail if needed containing the failed diks (fdisks) info.
if [ $sendm == 1 ]; then
  fdisks=${failed[@]}
  mail -s "$mname Disks $fdisks are about to fail." user@localhost < $logloc/diskerror.log
  rm -rf $logloc/diskerror.log
fi

#bash-2, #disk, #hard-disk, #health, #mail-2, #s-m-a-r-t, #script, #sda, #smart, #smartctl

Building Android on Gentoo

Ok, it is generally best practice to use Ubuntu  for building android but if you are a Gentoo fan and don’t want to mess with a vm you’ll have to bypass some bumps first.

So let’s start. Firstly you need sun-jdk6. icedtea-jdk won’t do the trick. So let’s get sun-jdk6 firstly. I’m going to just pass the commands you need and it should be self explanatory if you know what you are doing.

Download java and put it at /usr/portage/distfiles/

su-
cd /usr/portage/distfiles
wget http://uni-smr.ac.ru/archive/dev/java/SDKs/sun/j2se/6/jdk-6u45-linux-x64.bin

Then copy paste the exact same lines as below to auto-accept all licenses.


cat >> /etc/make.conf <<END
ACCEPT_LICENSE="*"
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --autounmask=n"
END

Then let’s unmask sun-jdk. It’s masked for security reason but we really need this. So edit  package.unmask with your favorite editor ( vi /etc/portage/package.unmask ) and add at the bottom


=dev-java/sun-jdk-1.6.0.45

Ok we’re ready let’s emerge


emerge dev-java/sun-jdk

After you’ve done select the appropriate package by issuing


java-config --set-system-vm sun-jdk-1.6

Afterwards let’s emerge all the packages we need to compile android.


emerge git app-crypt/gnupg flex bison gperf libsdl wxGTK squashfs-tools curl ncurses zlib schedtool perl-Switch zip unzip emul-linux-x86-baselibs emul-linux-x86-compat emul-linux-x86-cpplibs

You should be all done expect one last thing. repo sync etc. and before you start your build goto core/config.mk and comment out the following lines.


+#ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
+#$(error Error: could not find jdk tools.jar, please install JDK6, \
+#    which you can download from <a href="http://java.sun.com" target="_blank">java.sun.com</a>)
+#endif

You are good to go! Happy android building!

#android, #building, #endif, #gentoo, #ifeq, #requires_openjdk, #sun-jdk

Virtualbox: Kernel driver not installed (rc=-1908) CentOS/Fedora

Virtualbox Error

Virtualbox Error

This happens after a kernel update. Just install the following meta-package and reboot.

64bit

sudo yum install kmod-VirtualBox.x86_64

or for 32bit

sudo yum install kmod-VirtualBox.i686

#1908, #centos, #error, #fedora, #kernel-driver, #virtualbox, #virtualization

Joomla: 500 internal server error on administrator panel.

The solution is rather simple.
You need to set the right permissions for log , cache, tmp and administrator/cache.
So goto your joomla root dir and

chmod 755 log cache tmp administrator/cache

Also make sure the file ownerships are correct.

chown -R myuser myjoomladir

And last to get rid of “500 – An error has occurred” while logging to the admin read the error_log which should be like this

[16-Nov-2013 10:00:37 Europe/Athens] PHP Warning:  fopen(/home/myuser/www/logs/error.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied in /home/myuser/www/libraries/joomla/log/loggers/formattedtext.php on line 248

Meaning you have to

chmod 777 /home/myuser/www/logs/error.php

Also one last thing to keep in mind is you need to have the correct path for log and tmp at your configuration.php file. Something like that.

 public $log_path = '/home/myuser/public_html/logs';
 public $tmp_path = '/home/myuser/public_html/tmp';

All set!

[Ubuntu] WARNING: gnome-keyring:: couldn’t connect to: /tmp/keyring-*****/pkcs11

Do

sudo gedit /etc/xdg/autostart/gnome-keyring-pkcs11.desktop

replace

OnlyShowIn=GNOME;Unity

with

OnlyShowIn=GNOME;Unity;LXDE;XFCE

#gnome, #keyring, #linux, #openbox, #ubuntu