Redirect traffic from one interface to another

VPS (10.8.0.0/24) <——> (tun0) Server (ppp1) <——> iPhone (172.16.31.0/24)

iptables -A INPUT -p tcp –dport 109 -j ACCEPT

iptables -A INPUT -i ppp1 -j ACCEPT
iptables -A FORWARD -i ppp1 -j ACCEPT
iptables -A FORWARD -o ppp1 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -I POSTROUTING -s 172.16.31.0/24 -o ppp0 -j MASQUERADE
ip route add default dev tun0 table 200
ip rule add priority 100 from 172.16.31.0/24 table 200

iptables -t nat -I POSTROUTING -o tun0 -j SNAT –to 10.8.0.6

Reference: http://forums.gentoo.org/viewtopic-t-843591.html

Execute Perl scripts as root (Method 2)

1. Download exec-wrapper at http://code.google.com/p/exec-wrapper/downloads/detail?name=exec-wrapper-1.0.1.tar.bz2 or  http://hkvms.com/~alfred/exec-wrapper.tar.xz

Then you need to tweak the Perl scripts a little to avaoid warnings. If you are using the suidperl program you should replace #!/usr/bin/perl with the suidperl program (i.e. #!/usr/bin/suidperl) and use -U tag to execute unsafe commands.

#!/usr/bin/perl -wU

system(“/sbin/iptables”, “-L”);

And finally, you need to set the suid bit and change permissions of commands such as poff, pon, squid and cp to allow the CGI script to be executed as root.

# chown root:root <command name>
# chmod ug+s <command name>
# chmod a+x <command name>

Setting up a Rails Email Server

1. Download rvm.tar.xz from http://hkvms.com/~alfred/rvm.tar.xz

2. Download hkuso.tar.xz from http://hkvms.com/~alfred/hkuso.tar.xz

2. cd /usr/local

3. tar Jxvf /tmp/rvm.tar.xz

4. unzip hkuso.tar.xz to /home

5. gem uninstall rails “>3.2”

6. apt-get install libmysqlclient-dev

7. apt-get install postfix

8. source /usr/local/rvm/scripts/rvm and add source /usr/local/rvm/scripts/rvm ~/.bashrc

9. rvm requirements

/usr/bin/apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

10. rvm reinstall 1.9.3

11. apt-get install vrfy

12. modify from email in /home/hkuso/mail3/app/models/mailer1.rb

13. add info: root into /etc/aliases

14. add LANG=”en_US.UTF-8″ into /etc/default/locale

15. locale-gen en_US.UTF-8

16. type command vigr and then add rvm:x:1000:

17. type command vigr -s and then add rvm:!::

Passing values from html to a perl script

<<$Value= $FORM{‘Familia’};>>

For getting your value like this you should parse the form.

here i am writing an example showing how you can parse value from a form using POST Method.

#############
# Parse form

read(STDIN, $buffer, $ENV{‘CONTENT_LENGTH’});

#read the values from envourment variable .store in buffer.

@pairs = split(/&/, $buffer);

#split that buffer value

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

#separate name and values from the pair.

$value =~ tr/+/ /;
#remove all the + from value..
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(“C”, hex($1))/eg;
$value =~ s/<!–(.|n)*–>//g;
$value =~ s/<([^>]|n)*>//g;
$FORM{$name} = $value;
#assain all the value to name..
}
##############

now you can get the value like this.

$Value= $FORM{‘Familia’}

##############——-############-###########–

If you you can use cgi.pm module you can get the input very easily.
see this example..

test.htm

<form method=”post” action=”test.cgi”>

<select name=”Familia”>

<select size=”1″ name=”Familia”>
<option selected value=”one”>one</option>
<option value=”two”>two</option>
<option value=”three”>three</option>
</select>

<input type=”submit” name=”submit” value=”submit”>
</form>
test.cgi

#!/usr/perl/bin

use CGI;
#use CGI.pm module

$q=new CGI;
$value=$q->param(‘Familia’);

#get the parameter from name field
# and store in $value variable.

print $q->header;
#print the header
print “<html>n”;
print “<head><title>Test</title></head>n”;
print “<body>n”;

print “<h1>Testing form input</h1>n”;
print “<b>Selected value is: “.$value.”</b>n”;

#just call the $value varable here.
print “</body>n”;
print “</htm>n”;

Reference: http://forums.devshed.com/perl-programming-6/passing-values-from-html-to-a-perl-script-7977.html