Saturday, November 30, 2013

How to setup proxy autoconfiguration in Centos 6

Here are the steps to add a proxy configuration script to your squid server so that your browser will discover the proxy automagically.

First create the file /var/www/html/wpad.dat on your server. Add the following contents:

function FindProxyForURL(url, host) { return "PROXY mysquid:3128"; } 

This is the simplest javascript code to make it work. You can find more examples here.

If you haven't got httpd, install it

yum install httpd


Add a file wpad.conf in your /etc/httpd/conf.d directory with the contents:

<Directory /var/www/html>
Order deny,allow
Deny from all
# add IP address you allow
Allow from 172.16.1.1/16
</Directory>

Edit the /etc/httpd/conf/httpd.conf file and add the following lines to correctly set the mime type of the .dat file:

AddType application/x-ns-proxy-autoconfig .pac
AddType application/x-ns-proxy-autoconfig .dat

The browser will search for http://wpad/wpad.dat when discovering proxies.

Now the real trick is to add an address record (not an alias, this does not work with all browsers) in your DNS configuration that points to your apache server serving the wpad.dat file

A wpad.my-local-net.com 172.1.1.1 

Make sure to open the firewall for the apache web server serving your wpad.dat file.


How to avoid NetworkManager overwriting resolv.conf in Centos 6 (RHEL 6, Fedora)

This one took me a while to figure out mainly due to conflicting information on the web.

The easiest way to avoid NetworkManager to overwrite your /etc/resolv.conf when getting a dhcp lease is to create a new file /etc/dhcp/dhclient-eth0.conf. For some reason in Centos 6 Network manager will not pick up the /etc/dhcp/dhclient.conf or /etc/dhclient.conf files. Also sometimes it is good to delete the /var/run/nm-dhclient-eth0.conf file since sometimes this file will not be recreated.

Here is my /etc/dhcp/dhclient-eth0.conf file. Change eth0 to the name of your interface if different.

# /etc/dhcp/dhclient-eth0.conf
# Use Google DNS instead of DCHP provided
supersede domain-name-servers 8.8.8.8;
# Correctly set the local domain name
supersede domain-search "mydomain.com";
supersede domain-name "mydomain.com";

The supersede directive will replace the DHCP configuration with your own. If you wish to append or prepend, use the 'append' or 'prepend' directive.

Now regenerate the /etc/resolv.conf file

sudo service NetworkManager restart

Wednesday, November 27, 2013

Install VLC media player on Centos 6.4

# Script to install VLC player on Centos 6.4

#Install the EPEL repository
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

# Install RPMFusion
sudo yum -y localinstall --nogpgcheck http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm
sudo yum -y localinstall --nogpgcheck http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm

# Install VLC
sudo yum -y --enablerepo=remi-test install vlc

Installing Firebird 1.5 on Centos 6 32 bit (x86)

A while ago I needed to migrate a Firebird 1.5 server from Centos 5 to Centos 6 (to a new machine) since the old server had been running for 7+ years and it was time to give the old guy a break. I tried to install it in Centos 6 64 bit to no avail so I tried the 32 bit flavor and it worked as a charm. Here I provide a quasi-script to install all the dependencies, etc.

I tried my luck with the Classic Server first since I thought it would scale better since every connection would have its own process and use the whole 4GB per process limit on 32 bit, but the server would drop connections after 10+ users so I went with the SuperServer which was the Centos 5 configuration that worked well.


# Install dependencies

sudo su -l
yum -y install glibc.i686
yum -y install libstdc++.so.5
yum -y install libncurses.so.5

# Download Firebird Super Server

# Install Firebird package
rpm -i FirebirdSS-1.5.6.5026-0.i686.rpm

# Turn the service on at boot time
chkconfig --level 35 firebird on


# Optionally change the sysdba password
cd /opt/firebird
cat SYSDBA.password
bin/changeDBAPassword.sh


# Optionally create db path
mkdir /home/firebird
chown firebird:firebird /home/firebird


# Optionally Install flamerobin
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
yum -y install firebird-libfbclient
cd /root
wget http://downloads.sourceforge.net/project/flamerobin/flamerobin-snapshots/0.9.x/flamerobin-0.9.1.1806-i386-gtk2.tgz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fflamerobin%2Ffiles%2Fflamerobin-snapshots%2F0.9.x%2F&ts=1385064466&use_mirror=softlayer-dal
cd /
tar xvzf /root/flamerobin-0.9.1.1806-i386-gtk2.tgz


# Test flamerobin
ssh -Y user@server
flamerobin