Aug 31

A couple of days ago I had to install a Point-to-Point Tunneling Protocol (PPTP) Server on a Centos 5.6 distribution (was a favor for a friend). In this case it is used to create a simple Virtual Private Network (VPN) to tunnel all the traffic through the server’s internet connection.

1. Make sure that you have a kernel greater than 2.6.15 and that you have ppp-compress module installed.  Otherwise you will have to install a MPPE module.

[root@server ~]# uname -r
2.6.18-238.12.1.el5
[root@server ~]# modprobe ppp-compress-18
[root@server ~]#

2. Install ppp package:

yum -y install ppp

3. Download the PPTP daemon package and install it:

wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.rhel5.x86_64.rpm
rpm -ivh pptpd-1.3.4-2.rhel5.x86_64.rpm

4.  Make sure that you add the following lines to /etc/ppp/options.pptpd if these do not exist already (if you follow the exact steps in this tutorial, these should be already there):

[root@server ~]# cat /etc/ppp/options.pptpd |grep -v ^$ |grep -v ^#
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
[root@server ~]#

5. Now, you must take care of the /etc/pptpd.conf file. Here you define the IP address class used by the tunnel (this has nothing to do with your public IP address!)

[root@server ~]# cat /etc/pptpd.conf |grep -v ^$ |grep -v ^#
option /etc/ppp/options.pptpd
logwtmp
localip 192.168.86.254
remoteip 192.168.86.1-10
[root@server ~]#

6. It is time to add the credentials for the people using the Virtual Private Network in /etc/ppp/chap-secrets under the following format:

# client          server         secret          IP addresses
cristian          pptpd         mypassword            *

7. You must now make sure that you have packet forwarding enabled.

In /etc/sysctl.conf change the 0 to 1

net.ipv4.ip_forward = 0

will become

net.ipv4.ip_forward = 1

Now enable the changes using

sysctl -p

8. We want to tunnel all the traffic to the server’s Internet connection so we add the appropriate iptables firewall rule:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

9. Configure the PPTP Server to run at startup

chkconfig --level 35 pptpd on

10. And finally start it!

service pptpd start

Congratulations! I hope you now have a working PPTP Virtual Private Network.

written by Cristian \\ tags: , , , , ,

Aug 13

How to confuse an idiot

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Browsing the web, I found this funny new video ;)

written by Cristian \\ tags:

Aug 11

Today I’m going to show you a nice way to sync only specific files from user directories to a “fast speed download” server.

Basically, all my users upload resources (maps, sounds, models, etc) for a Counter Strike 1.6 Server through FTP. The issue was the fact that all these files had to be copied to a webserver, in order to be served using “sv_downloadurl “http://fast.howtodoityourself.org/cs” option from Counter Strike server.

And, of course, most of the users upload also crap on FTP in their directories and most of the times in different locations. So I used the option from PURE FTP server to use an upload script that is ran each time a user uploads a file/directory.

So, I created a script that checks for .res, .bsp, .wav, .mdl, .wad files and copies them on the high speed upload server at the correct location, meaning that any .bsp file will go to /var/www/cs/maps/ directory, any .wav file will end up in /var/www/cs/sound directory and so on.

Below, I provide you the full script, you may use it any way you want, of course I do not take any kind of responsibility for any loss you or your “victim” may suffer :)

By the way, for this you will need to have installed lftp client!

#! /bin/bash
INPUT=$1
LOG="/var/log/upload-script.log"
echo "Script BEGIN" >> $LOG
echo $INPUT >> $LOG
FULLPATH=${INPUT%/*}
echo "The path to the filename is $FULLPATH" >> $LOG
FILENAME=${INPUT##*/}
echo "The complete filename is $FILENAME" >> $LOG
BASENAME=${FILENAME%%.*}
echo "The name of the file (without the extension) is $BASENAME" >> $LOG
EXT=${FILENAME#*.}
echo "The actual extension is $EXT" >> $LOG

#We now truncate the extension to lowercase
EXT=`echo $EXT | tr '[A-Z]' '[a-z]'`
echo "The extension in lowercase is $EXT" >> $LOG

SWITCH="yes"
	if [[ $EXT = "bsp" ]]; then
		WAY=cs/maps
		echo "This is a map file" >> $LOG
		echo "The path to map files is $WAY" >> $LOG
	elif [[ $EXT = "wav" ]];then
		WAY=cs/sound
		echo "This is a sound file" >> $LOG
		echo "The path to sound files is $WAY" >> $LOG
	elif [[ $EXT = "spr" ]];then
		WAY=cs/sprites
		echo "This is a sprite file" >> $LOG
		echo "The path to sprite files is $WAY" >> $LOG
	elif [[ $EXT = "res" ]];then
		WAY=cs/resource
		echo "This is a resource file" >> $LOG
		echo "The path to resource files is $WAY" >> $LOG
        elif [[ $EXT = "mdl" ]];then
                WAY=cs/models
                echo "This is a model file" >> $LOG
                echo "The path to model files is $WAY" >> $LOG
	elif [[ $EXT = "wad" ]];then
		WAY=cs
		echo "This is a wad file" >> $LOG
		echo "The path to wad files is $WAY" >> $LOG
	else
	        echo "FUCK the dumb user" >> $LOG
		echo "The uploaded file has no reason to be on fast download server" >> $LOG
		SWITCH="no"
	        exit 1
	fi

HOST='howtodoityourself.org'
USER='myuser'
PASS='mypassword'
TDIR='/var/www'

if [ "$SWITCH" = "yes" ];then
TDIR="${TDIR}/${WAY}"
SDIR="/tmp/for_sync"

if [ -d $SDIR ];then
	echo "Sourcedirectory already exists" >> $LOG
else
	echo "Creating source directory $SDIR" >> $LOG
	mkdir $SDIR
fi
cp $INPUT $SDIR;

lftp -f "
open $HOST
user $USER $PASS
mirror --reverse --only-missing --Remove-source-files $SDIR $TDIR
bye
"
echo "UPLOAD SUCCESSFUL!" >> $LOG
fi

echo "Script END" >> $LOG
echo >> $LOG
echo >> $LOG

Of course, if there is anything that you do not understand, please post your question using the comments form.

written by Cristian \\ tags: , , , , , ,

Aug 01

This post will be related to the use of grep, sed, and awk to process text streams and files.

GREP

Is a command searches a file for lines containing a match to the given strings and prints the matching lines.
It is mainly used in the following combinations:

grep 'some string'  given_file
cat given_file | grep 'some string'
command | grep 'some string'

Continue reading »

written by Cristian \\ tags: , , , , ,