How to update the yum repository on Centos 5 server

How to update the yum repository on Centos 5 server

1) yum install yum-fastestmirror

2) yum install yum-priorities

3) uname -i

If the output is i386 then

cd /usr/local/src

wget  http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

4) Install key

rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

5)Install rpmforge

rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

6) yum check-update

It will take some time to update teh RPM and yum can create the  file named “primary.xml.gz”

After that you can able to install any software by using yum command
for exapmle yum install mplayer* , yum install ffmpeg etc..

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • Google Buzz
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Posted in How To Guides | Tagged , , | Leave a comment

Snom 720 & OpenVpn

Starting with firmware version 8.4.27, all Snom firmware versions for Snom 370, 8xx and 7×0 include the ability to build secure VoIP-Infrastructures via OpenVPN-Technology: in this post I will show step-by-step how to configure a Snom 720 to connect to an Asterisk pbx installed on CentOs 5.2.

The first step is to upgrade the firmware to the latest version. After this it is suggested to disable auto provisioning.

In order to disable auto provisioning the settings are located under Advanced -> Update. Set Update Policy to “Never update, do not load settings”. Set Subscribe Config and “PnP Config:” to off.

Now we have to enable the VPN by going to Advanced -> QoS/Security and selecting on, then reboot.

 

Now it is important verify all the configurations related the network and NTP (time server): all MUST be perfect !

Now on the server you have to install openvpn server and generate certificates for the clients. In the next some notes about this using the “distro” Pbx In a Flash.

cd /root
wget http://openvpn.net/release/openvpn-2.0.9.tar.gz
wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm
yum install rpm-build -y
yum install autoconf.noarch -y
yum install zlib-devel -y
yum install pam-devel -y
yum install openssl-devel -y
rpmbuild --rebuild /root/lzo-1.08-4.rf.src.rpm
rpm -Uvh /usr/src/redhat/RPMS/i386/lzo-*.rpm
rpmbuild -tb /root/openvpn-2.0.9.tar.gz
rpm -Uvh --force /usr/src/redhat/RPMS/i386/openvpn-2.0.9-1.i386.rpm
cp -r /usr/share/doc/openvpn-2.0.9/easy-rsa/ /etc/openvpn/
cp /usr/share/doc/openvpn-2.0.9/sample-config-files/server.conf /etc/openvpn/

Now you have to edit /etc/openvpn/easy-rsa/2.0/vars, and the next fields.

KEY_COUNTRY=
KEY_PROVINCE=
KEY_CITY=
KEY_ORG=
KEY_EMAIL=

Save the file.

chkconfig openvpn on
cp -R /etc/openvpn/easy-rsa/2.0/* /etc/openvpn/easy-rsa/
cd /etc/openvpn/easy-rsa/
. ./vars
./clean-all
./build-ca
source vars
./build-dh
./build-key-server server
cp keys/ca.crt ../
cp keys/dh1024.pem ../
cp keys/server.key ../
cp keys/server.crt ../
cp /etc/openvpn/server.conf /etc/openvpn/server.conf.orig
sed 's/dev tap/;dev tap/' /etc/openvpn/server.conf > /etc/openvpn/server.conf.tmp
sed 's/;dev tun/dev tun/' /etc/openvpn/server.conf.tmp > /etc/openvpn/server.conf.tmp1; cp /etc/openvpn/server.conf.tmp1 /etc/openvpn/server.conf
service openvpn restart

Now you have to verify that iptables does not block the port 1194/UDP.

The server-side is installed of Open-Vpn: we have to create client certificates.

cp /etc/openvpn/easy-rsa/vars /etc/openvpn/easy-rsa/2.0/
cp /etc/openvpn/easy-rsa/keys/* /etc/openvpn/easy-rsa/2.0/keys/
cd /etc/openvpn/easy-rsa
source ./vars
./pkitool <unique name for the certificate>

Now we have the openvpn server installed and 1 certificate to use with Snom Phone: you have to copy in a separate directory these files.

ca.crt
<unique name for the certificate>.crt
<unique name for the certificate>.key

Oss.: You can find all these files in /tc/openvpn/easy-rsa/keys.

In this same directory you have to create a file named vpn.cnf

vpn.cnf

client
dev tun
proto udp
remote <public ip address of the pbx> 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca /openvpn/ca.crt
cert /openvpn/<unique name for the certificate>.crt
key /openvpn/<unique name for the certificate>.key
ns-cert-type server
verb 3
ping 10
ping-restart 60

Att.: You should not change the name vpn.cnf and the path /openvpn/ inside the file: all the files must be in the same directory.

Inside this directory you have to create the tar that contains all these files.

cd /etc/openvpn
chown -Rf root:root *
chmod -R 700 *
tar cvpf vpnclient.tar *

The created file vpnclient.tar must be copied inside a directory that is accessible from http. I.e. if you use Pbx In A Flash you can use /var/www/html/vpnclient (you have to create the dir vpnclient.

Now you have to return to the web interface of the phone. In Advanced -> QoS/Security now are visible the fields “Unzip VPN config tarball” and “Netcat Server”: you have to insert the http path to you file.

I.e. http://<public ip address>/vpnphone/vpnclient.tar

Save & reboot !

To debug the connection from the phone to vpn server you can use a netcat software activated in a different machine to obtain all the logs. I.e. in debian server to activate this server you can use the next line

netcat -l -p 5000

After this you in the Snom in the field ”Netcat Server” you have to insert the next.

<ipaddress of the debian server> 5000

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • Google Buzz
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Posted in Recent Client Installs | Leave a comment

Enterprise deployment OpenSIPS…

Introduction

A load balancer setup can share load between multiple FS hosts according to load. A single ingress IP can be presented to the customer for the entire cluster simplifying the customer configuration (this can be combined with DNS SRV to give failover between data centres). The load balancer will measure load on each server in the cluster and send calls to the least loaded server. This ensures that the call load is spread among servers evenly, so no server

SIP signalling goes via the load balancer server, but media goes direct between the customer endpoint and the FS host in the cluster. This is similar to the bypass media functionality of FS. Since media does not go through the OpenSIPS server, the hardware requirements are far smaller that for the FS hosts in the cluster.

For the purposes of the example of this page there are 2 load balancer servers lb1 (100.100.100.101) & lb2 (100.100.100.102) and 4 FreeSWITCH servers (fs1-fs4, 100.100.100.103 – 100.100.100.106). All are on the same subnet (255.255.255.0). The virtual IP is 100.100.100.100.

Loadbalancer Configuration

For redundancy you should have two servers that act as load balancers. These will be in an active-passive configuration, i.e. all traffic goes via the active server the passive server is promoted to active if the active server fails or is taken down for maintenance. They each have their own IP so that they can be accessed independantly (e.g. via SSH for maintenance) and share a virtual IP which is assigned to the current active server. SIP traffic is accepted on the virtual IP.

It is recommended that lb1 and lb2 have multiple ways to communicate, to prevent a split brain situation where both lb1 and lb2 think the other is offline and both start listening on the virtual IP.

Heartbeat

Heartbeat is responsible for assigning the virtual IP to a server and detecting when the other server fails.

You will need to create 3 files in /etc/heartbeat: authkeys, ha.cf, haresources. These files must be identical on both lb1 and lb2.

authkeys

This file stores one or more authentication methods, and selects which to use with the auth statement. For example:

auth 2
1 crc
2 sha1 thisismysecretkey
3 md5 thisismysecretkey

The key here is used to authenticate communication between nodes in the cluster and prevents malicious servers being able to trick a node into going offline. As a result it should be kept secret and very secure. CRC should never be used in production as it provides no authentication, just error checking.

ha.cf

This is only an example. Timings can be adjusted to suit your needs. This uses a serial cable and network broadcast to check the other node but 1 or more of serial, unicast, multicast and broadcast can be used and none is required (apart from there must be at least one communication method).

# Logging
logfacility     local0

# Timings
keepalive 100ms
deadtime 2
warntime 1
initdead 120

# Communication between nodes - serial port
baud   19200
serial /dev/ttyS0

# Communication between nodes - network
udpport 694
bcast   bond0

# What nodes are in the cluster
node lb1 lb2

# Control whether a resource will automatically fail back to its "primary" node
# or remain on the current node until it fails/admin intervenes
auto_failback off

# Processes started and stopped with heartbeat.  Restarted unless they exit with rc=100
respawn hacluster /usr/lib/heartbeat/ipfail

# API Authentication
apiauth ipfail gid=haclient uid=hacluster

haresources

This file controls what resources are configured on the load balancer servers, this is where the virtual IP is configured. The format is:

preferred_hostname IPaddr2::ip_address/netmask(/interface)

Interface is optional, but for our example there are two NICs (eth0 and eth1) bonded to form bond0 for network redundancy.

For example:

lb1 IPaddr2::100.100.100.100/255.255.255.0/bond0

Sysctl

OpenSIPS will bind to the virtual IP. This will result in an error on the passive server which prevents OpenSIPS starting up since it will be attempting to listen on an IP that does not belong to it. This can be avoided by setting the Linux option net.ipv4.ip_nonlocal_bind=1.

On debian this can be achieved by creating the file /etc/sysctl.d/linuxha.conf:

# allow services to bind to the virtual ip even when this server is the passive machine
net.ipv4.ip_nonlocal_bind = 1

OpenSIPS

This example listens for both UDP and TCP SIP calls on the virtual IP.

The dispatcher is used distribute REGISTER requests among the FreeSWITCH hosts. It uses the OPTIONS packet to detect when a FreeSWITCH host is offline and stop sending requests to that host. Dispatcher uses weights and doesn’t take server load into account; this is ok for REGISTER requests but unsuitable for actual calls.

The load_balancer module is used to distribute INVITE requests (calls). It also uses OPTIONS to automatically stop sending traffic to a host if it goes offline. Unlike dispatcher, it stores the number of channels available on a host and in memory keeps a count of how many calls are currently in progress to that host, sending the INVITE to the least loaded host.

load_balance() takes an algorithm as the 3rd option – either 0 (absolute) or 1 (relative). The example here uses relative, so the “least loaded” server is the one with the lowest percentage load (current_channels/max_channels) while absolute would send to the one with the most free channels (maximum_channels-current_channels).

OpenSIPS 1.7 install guide on CentOS 5.6:

[root@opensips1~]# yum install gcc-c++ bison lynx subversion flex
[root@opensips1~]# wget http://opensips.org/pub/opensips/1.7.0/src/opensips-1.7.0_src.tar.gz
[root@opensips1~]# tar zxvf opensips-1.7.0_src.tar.gz
[root@opensips1~]# cd opensips-1.7.0-tls
[root@opensips1~]# make all include_modules="db_mysql"
[root@opensips1~]# make include_modules="db_mysql" prefix="/usr/local" install

Edit /usr/local/etc/opensips/opensipsctlrc and uncomment the line that says DBENGINE=MYSQL

[root@opensips1~]# vi /usr/local/etc/opensips/opensipsctlrc
DBENGINE=MYSQL

Create the OpenSIPS database:

[root@opensips1~]# opensipsdbctl create

Create the OpenSIPS MySQL user, password and grant privileges to openips database:

[root@opensips1~]# mysql -p
mysql> grant all privileges on opensips.* to opensips@localhost identified by 'opensips';

While still in MySQL CLI add the FreeSWITCH machines into the load_balancer table:

mysql> use opensips;
mysql> insert into load_balancer (group_id, dst_uri, resources, description) values (1,'sip:100.100.100.103', 'pstn=32', 'FS1');
mysql> insert into load_balancer (group_id, dst_uri, resources, description) values (1,'sip:100.100.100.104', 'pstn=32', 'FS2');
mysql> insert into load_balancer (group_id, dst_uri, resources, description) values (1,'sip:100.100.100.105', 'pstn=32', 'FS3');
mysql> insert into load_balancer (group_id, dst_uri, resources, description) values (1,'sip:100.100.100.106', 'pstn=32', 'FS4');
mysql> quit;

Copy the OpenSIPS startup script:

cp /usr/src/opensips-1.7.0-tls/packaging/rpm/opensips.init /etc/init.d/opensips
sed -i "s/\/usr\/sbin\/opensips/\/usr\/local\/sbin\/opensips/g" /etc/init.d/opensips
sed -i "s/\/etc\/opensips/\/usr\/local\/etc\/opensips/g" /etc/init.d/opensips
sed -i "s/\/etc\/default\/opensips/\/usr\/local\/etc\/opensips/g" /etc/init.d/opensips
sed -i "s/RUN_OPENSIPS=no/RUN_OPENSIPS=yes/g" /etc/init.d/opensips
chmod +x /etc/init.d/opensips

Add user ‘opensips’:

useradd -d /usr/local/etc/opensips -s /sbin/nologin opensips

Start opensips and add the FreeSWITCH machines into the dispatcher table:

[root@opensips1~]# service opensips start
[root@opensips1~]# opensipsctl dispatcher addgw 1 sip:100.100.100.103 0 'FS1'
[root@opensips1~]# opensipsctl dispatcher addgw 1 sip:100.100.100.104 0 'FS2'
[root@opensips1~]# opensipsctl dispatcher addgw 1 sip:100.100.100.105 0 'FS3'
[root@opensips1~]# opensipsctl dispatcher addgw 1 sip:100.100.100.106 0 'FS4'

Edit opensips.cfg:

vi /usr/local/etc/opensips/opensips.cfg

Copy and paste into opensips.cfg:

####### Global Parameters #########

debug=3
log_stderror=no
log_facility=LOG_LOCAL0

fork=yes
children=4

disable_tcp=no

dns_try_ipv6=no

auto_aliases=no

/* bind on the machine's virtual ip (note: enable sys.net.ipv4.ip_nonlocal_bind) */
listen=udp:100.100.100.100:5060
listen=tcp:100.100.100.100:5060

####### Modules Section ########

#set module path
mpath="/usr/local/lib/opensips/modules/"

loadmodule "db_mysql.so"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "uri.so"
loadmodule "dialog.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
loadmodule "dispatcher.so"
loadmodule "load_balancer.so"

# ----------------- setting module-specific parameters ---------------

modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

modparam("dialog", "db_mode", 1)
modparam("dialog", "db_url", "mysql://opensips:opensips@localhost/opensips")

modparam("rr", "enable_double_rr", 1)
modparam("rr", "append_fromtag", 1)

modparam("tm", "fr_timer", 2)

modparam("dispatcher", "db_url", "mysql://opensips:opensips@localhost/opensips")
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_interval", 5)
modparam("dispatcher", "ds_probing_threshhold", 2)
modparam("dispatcher", "ds_probing_mode", 1)

modparam("load_balancer", "db_url", "mysql://opensips:opensips@localhost/opensips")
modparam("load_balancer", "probing_method", "OPTIONS")
modparam("load_balancer", "probing_interval", 5)

####### Routing Logic ########

# based on http://www.opensips.org/index.php?n=Resources.DocsTutLoadbalancing
route{

        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        }

        if (!has_totag()) {
                # initial request
                record_route();
        }
        else {
                # sequential request - obey the indicated route
                loose_route();
                t_relay();
                exit;
        }

        # handle cancel and re-transmissions
        if ( is_method("CANCEL") ) {
                if ( t_check_trans() )
                        t_relay();
                exit;
        }

        # from now on we have only the initial requests

        # select the node that'll handle the call (load balanced)
        # the method used is different for invite/register requests
        # unknown methods are rejected here
        if (is_method("INVITE")) {
                if (!load_balance("1","pstn","1")) {
                        send_reply("503","Service Unavailable");
                        exit;
                }
        }
        else if (is_method("REGISTER")) {
                if (!ds_select_dst("1", "0")) {
                        send_reply("503","Service Unavailable");
                        exit;
                }
        }
        else {
                send_reply("405","Method Not Allowed");
                exit;
        }

        # route the request
        if (!t_relay()) {
                sl_reply_error();
        }
}

Restart OpenSIPS:

service opensips restart

Done!

MySQL Cluster

For calls to failover without dropping, the dialogs module must share its information in a shared database. This then means that on failover UDP calls will not be dropped since OpenSIPS will still know where to forward any SIP packets passing through the passive (now active) server as they’ll be in its database. TCP calls cannot failover as gracefully in this way because the TCP connection will not be known to Linux/OpenSIPS on the passive server.

The database also provides a source for the list of hosts and weights/channels for the dispatcher and load_balancer modules. These must be told to reload the data from the database via a MI module if the database is updated.

There are multiple methods for setting up a shared database. You can have a single database, but this provides a point of failure. You can also have a pair of database servers with master-master, but this can cause problems since the replication is asynchronous. The MySQL Cluster solution provides a nice solution.

For a fully redundant setup, you should have at least 2 management servers, 2 data nodes and 2 sql nodes. All can be on the same hardware or on dedicated hardware. For this example they’ll all run on lb1 and lb2, but in real usage it might be advisable to move them onto separate servers to reduce the load on the load balancer servers. This could be a LAN which lb1 & lb2 are also on, to remove them from the public Internet (this is advisable since MySQL Cluster uses no authentication/encryption).

FreeSWITCH Configuration

FreeSWITCH needs very little additional configuration to function with the load balancer setup. Your existing setup will mostly work just fine. There are a couple of areas that will need attention though.

Authentication

User authentication would just fine, as the 401 Not Authorized and authentication headers are forwarded by the SIP proxy.

ACLs might be trickier however, since the requests will all come from the virtual IP.

TODO: is it possible to get FreeSWITCH to authenticate against an ACL from a value in a header if the request comes from an IP matching a proxy ACL? If so OpenSIPS could add an IP header

SIP Registrations

REGISTER requests will go to a host in FreeSWITCH cluster. For the other hosts to know about the registration they will need to store the mod_sofia data in a shared database (single database, master-master replication or MySQL cluster). All hosts must also be configured to handle calls for the same domain, and the registration must be to this domain.

CDRs

The network IP logged in the CDRs will be that of the load balancer not the client’s IP, this should be beared in mind.

Source : http://wiki.freeswitch.org/wiki/Enterprise_deployment_OpenSIPS

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • Google Buzz
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Posted in Little Guides, Personal Projects | Tagged , , , | Leave a comment

Adding a OpenVPN client on ubuntu 10.04…

First the certificate (key) should be created on the server.

cd /etc/openvpn/easy-rsa/
source vars
./pkitool hostname

Copy the certificate files to the client
* /etc/openvpn/ca.crt
* /etc/openvpn/easy-rsa/keys/hostname.crt
* /etc/openvpn/easy-rsa/keys/hostname.key

Then the client should be setup

apt-get install openvpn
cd /etc/openvpn
cp /usr/share/doc/openvpn/examples/sample-config/client.conf client.conf

Edit the client.conf file (edit all that you need to fit your config, the following are those I recommend):
The fix for Vista I add (commented out) since I am lazy and usually just copy a old config file to the next client

remote my.domain.com 1194

# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
ca ca.crt
cert clientName.crt
key clientName.key

#fix for vista being stuid...
;route-method exe
;route-delay 2

Restart OpenVPN on the client:

 /etc/init.d/openvpn restart
 * Stopping virtual private network daemon(s)...
 *   No VPN is running.
 * Starting virtual private network daemon(s)...
 *   Autostarting VPN 'myVPN'                                         [ OK ]

Same as with the server, the above means that is went well, a [fail] means that the logs should be read for details.

A word of caution: [ OK ] only means that the OpenVPN was started ok – no errors in config etc.
There might still be issues with firewalls, wrong hostname (to the server) etc.
Check ifconfig and ping the server to make sure it is working.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • Google Buzz
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Posted in How To Guides, Little Guides, Recent Client Installs, Usefully Found Stuff | Tagged , | Leave a comment

How To setup SSH Key Authentication on Linux

This short tutorial explains how to setup SSH to use key based authentication, by default on CentOS this is disabled. To start with follow our guide on how to generate SSH key pairs and copy the key over.

Configure SSH to enable Public Key Based Authentication

Open up /etc/sshd_config in vi and find the following lines:

#PubkeyAuthentication yes
#AuthorizedKeysFile      .ssh/authorized_keys

And un-comment them so it reads:

PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

Restart SSH Server with:

/etc/init.d/sshd restart

You should now be able to login over SSH using public key based authentication.

Article source: http://feedproxy.google.com/~r/linuxmoz/~3/VQ4FeVueKrs/

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • Google Buzz
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Posted in Little Guides, Usefully Found Stuff | Tagged , , , , | Leave a comment