Prefer/Precedence IPv4 over IPv6 for DNS lookups

We had an issue with DNS lookup/Querying the whois servers(Example: while Domain Search/Registration for any TLDs through WHMCS, Domain Manager etc. The tool/system used to timeout whenever the users searched a domain for availability.

We found the following via CLI when telnet’ing to the whois server directly.

[root@host ~]# telnet 43
Trying 2620:74:20::30...
telnet: connect to address 2620:74:20::30: Connection refused
Trying 2620:74:21::30...
telnet: connect to address 2620:74:21::30: Connection refused
Connected to
Escape character is '^]'.

The above indicates it attempts IPv6 DNS lookup first but the whois server doesn’t support or provide it, later our server tries IPv4 DNS lookup and it worked.

The system by default uses AAAA(IPv6) DNS lookups before IPv4 according to the default precedence blocks in /etc/gai.conf (gai stands for getaddrinfo, the standard system call for resolving host names).

As many prefer to disable IPv6 completely and it is not a good solution on the servers which require IPv6 for other purposes, we can try an alternative solution by giving precedence to IPv4 over IPv6 without disabling IPv6.

This is done by changing “precedence ::ffff:0:0/96 10" toprecedence ::ffff:0:0/96 100" in the config file /etc/gai.conf. Check whole /etc/gai.conf to read and understand.

[root@host ~]# grep "::ffff:0:0/96" /etc/gai.conf
#label ::ffff:0:0/96 4
#precedence ::ffff:0:0/96  10
precedence ::ffff:0:0/96  100

If you do not have a /etc/gai.conf(which controls the getaddrinfo() call), you should have an example somewhere within /usr/share/doc (on Centos/RHEL, it is at /usr/share/doc/glibc-common-X.XX.XX/gai.conf) which you can copy over to /etc/gai.conf.

Mine was at:

[root@host ~]# rpm -qa glibc*

[root@host ~]# ll /usr/share/doc/glibc-common-2.17/gai.conf
-rw-r--r--. 1 root root 2584 Jul  3 15:25 /usr/share/doc/glibc-common-2.17/gai.conf

[root@host ~]# cp -pv /usr/share/doc/glibc-common-2.17/gai.conf /etc/
‘/usr/share/doc/glibc-common-2.17/gai.conf’ -> ‘/etc/gai.conf’

Then it started working fine by giving preference to IPv4 over IPv6.

[root@host ~]# telnet 43
Connected to
Escape character is '^]'.
Connection closed by foreign host.

Error while installing any package using apt-get

I was getting the following error while I tried to install any package using apt-get package manager.

For example:


# apt-get install wget
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/extra.linuxmint.com_dists_rafaela_main_i18n_Translation-en
E: The package lists or status file could not be parsed or opened.


# rm -vf /var/lib/apt/lists/*

Then do,

# apt-get update

Finally, I was able to install packages using apt-get

# apt-get install wget
Reading package lists... Done
Building dependency tree Reading state information... Done
wget is already the newest version.The following packages were automatically installed and are no longer required:
empathy-common libfarstream-0.2-2 libfolks-telepathy25 libfolks25libgssglue1 libtelepathy-farstream3 libtelepathy-logger3 libtirpc1python-gst0.10 telepathy-logger
Use 'apt-get autoremove' to remove them.0 upgraded, 0 newly installed, 0 to remove and 273 not upgraded.2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up chromium-codecs-ffmpeg-extra (45.0.2454.101-0ubuntu0. ...Setting up chromium-browser (45.0.2454.101-0ubuntu0. ...Done...

How to change username when you have only one account in Ubuntu?

You cannot simply login as root in Ubuntu at the start up. Do it as the following way:

1) Open terminal and switch to root user. You can open terminal in search or by pressing Ctl+Alt+t.

2) Unlock root account and enable login as root like below

# passwd -u root (:::should be as root)

3) Reboot the machine

4) Once the login page appears, press Ctrl+Alt+Fx (x can be from 1 to 6) to open a terminal. Then switch root user and enter root password.

5) Change the username of account you wanted to.

# usermod -l newname oldname

6) Change the home folder name of user to new one if you want to. But this is optional.

# usermod -m -d /home/newname newname ((this would change home/oldname to /home/newname))

7) Lock the root account again

# passwd -l root

8) Switch back to GUI(the graphical login page at startup)

# Ctl + Alt + F7

(If it’s not working just reboot using “reboot” or “shutdown -r now” command)

Login with new username and enjoy working 🙂

((Above method is needed when only single user account is present in ubuntu. When you have only one account, you cannot do this username change by standing in the same account environment))

Install Skype in Ubuntu

Download debian package for Skype from the following url, from it I chose Ubuntu multi arch version.

After downloading skype-ubuntu-precise_4.3.0.37-1_i386.deb , install it with dkpg which is the package manager for Debian version.

# dpkg -i skype-ubuntu-precise_4.3.0.37-1_i386.deb

If you get an error on it

  Errors were encountered while processing:

# skype
skype: error while loading shared libraries: cannot open shared object file: No such file or directory

Now we can check its file type

# file /usr/bin/skype
/usr/bin/skype: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xa888f203730ac8ff33ae0261a95129dbb76e1857, stripped

so it’s shared object and dynamically linked to shared libraries, and there might be problem some of is dependancies.

You can check dependant libraries of this package by using ‘ldd’ command

# ldd /usr/bin/skype =>  (0xf77b4000) => not found => not found => /lib/i386-linux-gnu/ (0xf5515000) => /lib/i386-linux-gnu/ (0xf5510000) => /usr/lib/i386-linux-gnu/ (0xf53db000) => /usr/lib/i386-linux-gnu/ (0xf53c8000) => not found => not found => not found => not found => not found => not found => /lib/i386-linux-gnu/ (0xf53ab000) => /usr/lib/i386-linux-gnu/ (0xf52c2000) => /lib/i386-linux-gnu/ (0xf527f000) => /lib/i386-linux-gnu/ (0xf5262000) => /lib/i386-linux-gnu/ (0xf50ae000)
    /lib/ (0xf77b5000) => /usr/lib/i386-linux-gnu/ (0xf508c000) => /usr/lib/i386-linux-gnu/ (0xf5088000) => /usr/lib/i386-linux-gnu/ (0xf5081000)

Here I have got many missing dependancies libraries and offcourse broken ones.

You can install broken dependancies using ‘apt-get’ command with ‘-f’ option along with it. ‘-f’ is for correcting a system with broken dependencies.

# apt-get -f install

and continue installation.

Now install debian package of skype again.

# dpkg -i skype-ubuntu-precise_4.3.0.37-1_i386.deb
(Reading database … 192226 files and directories currently installed.)
Preparing to replace skype (using skype-ubuntu-precise_4.3.0.37-1_i386.deb) …
Unpacking replacement skype …
Setting up skype ( …
Processing triggers for hicolor-icon-theme …
Processing triggers for gnome-menus …
Processing triggers for desktop-file-utils …
Processing triggers for bamfdaemon …
Rebuilding /usr/share/applications/bamf-2.index…
Processing triggers for mime-support …

You are done…. 🙂

/etc/resolv.conf is being overwritten everytime??? | Ubuntu work around

Yes it is true in ubuntu, even if we manually set custom nameservers in /etc/resolv.conf it will overwrite on next reboot or network restart or modem/router restart. It is really annoying once we set google nameservers or opendns or whatever in resolv.conf it goes back to default page on each instance of restart or modem reconnect. The operation of setting attribute to /etc/resolv.conf is not supported here.

root@vaiocyber:~# chattr +i /etc/resolv.conf
chattr: Operation not supported while reading flags on /etc/resolv.conf

The work around to get it permanently fixed is as follows:

Initially my resolv.conf looked like.

root@vaiocyber:~# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
search Home

Open file /etc/network/interfaces and add the line “dns-nameservers NS1-IP NS2-IP” to the bottom, like I wanted to add opendns IPs in my system. For that I did add “dns-nameservers” to the interfaces file. Now the file looks like in my ubuntu is.

root@vaiocyber:~# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Now restart network by “service networking restart” or “ifdown eth0 ; ifup eth0” or Reboot modem or Reboot the ubuntu machine itself. From now onwards the custom nameservers we set will still there be in place until we revert the changes made 😀

After restart, the resolv.conf file will automatically added with custom nameservers we set in interfaces file 🙂


root@vaiocyber:~# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
search Home

Enjoy fast surfing now 🙂


(For more detailed information… read “man resolvconf“)

Install Java and Enable it for Web Browsers | Linux

(Steps based on what I did in Ubuntu OS)

As you know Java is essential to be installed and should be enabled to web browsers on local machines from where the system admins access their servers. The need of Java in most cases while we access consoles like KVM switches, IPMI etc to reboot a server which is down or to check what’s happening inside the server when SSH and network is down. In such cases, Java applet programs from the server would access our local machines and needs Java present in our machine inorder to run to work with web browser.

The local machines without Java installed or Webbrowsers not enabled with Java plugins will pop up errors like as follows when you load KVM or IPMI pages:






Following are the steps to install Java and enable it for Mozilla-firefox and Chromium Web Browsers in Ubuntu OS.


1) Go here >>

Download Java source, looks like “jre-7u51-linux-x64.tar.gz”. Note to choose source package based on your machines architecture 32bit or 64bit(Run ‘arch’ or ‘uname -m’ to check it)

2) Once downloaded, move the source package to path /usr/local/java. If folder doesn’t exist create one “mkdir /usr/local/java”

(Make sure you have the power to run all commands using sudo if you are a normal user, else be logged in as root)

#mv /home/john/Downloads/jre-7u51-linux-x64.tar.gz /usr/local/java/

#cd /usr/local/java/

#tar xvf jre-7u51-linux-x64.tar.gz

(You will see it untarred and everything in a folder named ‘jre1.7.0_51’)

#chown root.root /usr/local/java/ -R

3) Now open the file “/etc/profile” and add the following on top

export JRE_HOME
export PATH

4) Now run the below commands to let OS know the path where Java JRE is located and set.

#update-alternatives –install “/usr/bin/java” “java” “/usr/local/java/jre1.7.0_51/bin/java” 1

#update-alternatives –install “/usr/bin/javaws” “javaws” “/usr/local/java/jre1.7.0_51/bin/javaws” 1

#update-alternatives –set java /usr/local/java/jre1.7.0_51/bin/java

#update-alternatives –set javaws /usr/local/java/jre1.7.0_51/bin/javaws

5) Reload your system wide PATH /etc/profile by typing the following command:

# . /etc/profile

(Sometimes you may need to reboot your ubuntu system to reload the system wide PATH in /etc/profile)

Now Java is installed, check the version by using “java -version”

For Chromium

# cd /usr/lib/chromium-browser/plugins/
# ln -s /usr/local/java/jre1.7.0_51/lib/amd64/
# root@vaiocyber:/usr/lib/chromium-browser/plugins# ll
total 8
drwxr-xr-x 2 root root 4096 Mar 30 12:48 ./
drwxr-xr-x 7 root root 4096 Mar 17 03:14 ../
lrwxrwxrwx 1 root root 49 Mar 30 12:48 -> /usr/local/java/jre1.7.0_51/lib/amd64/*

Exit and reload Chromium browser now and load the KVM or IPMI page successfully 🙂
For enabling Java plugin permanently, in the address bar type “about:plugins” or “chrome://plugins/” . Choose “Java(TM) – Version: 10.x.x”
from the plugins list and check “Always allowed”.


For Mozilla Firefox

# cd /usr/lib/mozilla/plugins
# ln -s /usr/local/java/jre1.7.0_51/lib/amd64/
root@vaiocyber:/usr/lib/mozilla/plugins# ll
total 372
drwxr-xr-x 2 root root 4096 Mar 30 12:50 ./
drwxr-xr-x 4 root root 4096 Oct 17 00:31 ../
lrwxrwxrwx 1 root root 37 Mar 2 08:06 -> /etc/alternatives/mozilla-flashplugin
lrwxrwxrwx 1 root root 49 Mar 30 12:50 -> /usr/local/java/jre1.7.0_51/lib/amd64/*
-rw-r–r– 1 root root 6088 May 16 2013
-rw-r–r– 1 root root 100720 May 26 2013
-rw-r–r– 1 root root 105440 May 26 2013
-rw-r–r– 1 root root 72048 May 26 2013
-rw-r–r– 1 root root 80576 May 26 2013

Exit and reload Firefox now and load the KVM or IPMI page successfully 🙂
For enabling Java plugin permanently, click on Tools menu >> Add-ons, select “plugins” tab and set Java plugin “Always Active”.