Monday, September 05, 2005

OddMuse Wiki


For those who don't know what a wiki is, Google it yourself.

I came across this wiki engine on the internet. Actually, this wiki has been featured on Linux Journal magazine as well. It is written in Perl and uses flat files as database; no need to install and configure any external DB servers like MySQL.

The script can be downloaded from this site:

http://www.emacswiki.org/scripts/current

Save the script unto the web server's cgi directory. Name it anything you like (e.g. my_wiki.pl). Make sure it's executable (if this applies to you, I'm using Linux).

chmod +x my_wiki.pl

Make sure perl interpreter is up and running:

perl --version && which perl

Edit the script to reflect the correct perl interpreter path. If everything is properly setup, then try it out on your web browser:

http://your-ip-address/cgi-bin/my_wiki.pl

Enjoy!

Thursday, September 01, 2005

FTP Basics


A typical FTP (File Transfer Protocol) session goes like:
(1) open a remote host with an FTP server running.
(2) login
(3) create or copy to or copy from files, etc
(4) close the connection

An FTP session can also be automated by using script files.

Sample:
(1) connecting to a remote host:
- on the command prompt, simply type in: ftp ip_address
- or, type in ftp and then on the ftp prompt, type open ip_address

(2) login
- enter with your username and password
- this account is created by the Admin of the remote host you are connecting to

(3) perform FTP transactions
- display all commands by typing: help
- list the files on the remote server by typing: ls
- put a file to the remote server by typing: put filename
- get a file from the remote server by typing: get filename

(4) close the connection
- simply type: bye

Automating FTP:
(1) When using a Windows machine.
- create a script file that contains the FTP commands you wanted to perform, say we named it script.txt and has the following contents:
open ip_address
username
password
ftp commands
bye
- then simply type in: ftp -s:script.txt on the command prompt to execute

(2) When using a Linux machine.
- you can create a shell script file that looks like the following:
#!/bin/sh
ftp -n -i ip_address <<EOF
user username password
ftp commands
bye
EOF
exit 0

Wednesday, August 31, 2005

Debian Linux 3.0 on iBook as a Wifi router


1. make sure both ethernet and wifi connections are good

# ifconfig eth0 && ifconfig eth1

2. iwconfig eth1 should show it's connected to an AP somewhere - set SSID to "Any" so that it will try to auto-connect.

3. run this script:

# delete old configuration, if any
# flush all the rules in filter and nat tables
iptables --flush
iptables --table nat --flush

# delete all chains that are not in default
# filter and nat table
iptables --delete-chain
iptables --table nat --delete-chain

# setup IP FORWARDING and MASQUERADING (NAT)
iptables --table nat --append POSTROUTING
--out-interface eth0 -j MASQUERADE

iptables --append FORWARD --in-interface eth1
-j ACCEPT

iptables --append FORWARD --in-interface eth2
-j ACCEPT

# enable forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

4. update kernel routing table

(if wifi subnet is 169.254.0.0 and ethernet
subnet is 157.184.0.0)
- route command should return something like:
157.184.0.0 * 255.255.0.0 blah blah eth0
169.254.0.0 * 255.255.0.0 blah blah eth1

- you can add a subnet by:
route add -net 169.254.0.0 netmask 255.255.0.0 dev eth0

- should add a default by:
route add -net 0.0.0.0 dev eth0

- then update iptables for the specific device
iptables -A PREROUTING -t nat -p tcp
-d 168.254.x.x -j DNAT
--to 157.184.x.x
OR
iptables -A PREROUTING -t nat -p tcp
-d 168.254.x.x
--dport 80 -j DNAT
--to 157.184.x.x:80

5. the connecting device should have the following settings:

ip: 169.254.x.x
mask: 255.255.255.0
gateway: 169.254.x.x - the router's ip (ibook)
internet proxy: 157.184.x.x - internet proxy