Default style (Cherry Eve). Switch styles (Capricorn). XML Feed Calendar
All | General
20040909 Thursday September 09, 2004

Connecting to home

I am using a wireless router for my home internet connection, that says, all my home computers will be behind a firewall. To connect my home computers from office, Ineed to:

  • know the ip address of my router (it was allocated by ISP dynamicly);
  • enable router's "port forwarding" function to forward the accessing of special port (say 20, 21 for FTP) to a particular computer.

Firstly, create a perl script in a http server to determine the remote ip address:

#!/usr/bin/perl -w

print "Content-type: text/plain\n\n";
$query_string = $ENV{'REMOTE_ADDR'};
print "$query_string";

Then, use another perl script poking that server to get the real internet address:

#!/usr/bin/perl

use IO::Socket;

$server = 'site';
$port = 80;
$script = '/path/to/cgi/myip.cgi';

$socket = IO::Socket::INET->new(
 Proto => 'tcp',
 PeerAddr => $server,
 PeerPort => $port,
 Timeout => 10,
 );
unless($socket) {
 die("Could not connect to $server:$port");
}
$socket->autoflush(1);
print $socket ("GET $script HTTP/1.0\nHost: $server\nUser-Agent: YY\n\n");

$ip = "";
$off = 1;
while ($line = <$socket>) {
 $off = 0 if ($line =~ /^\s*$/)?
 unless ($off) {
     $ip = $line if (length($line) > 0)?
 }
}

[snip]

Finally, I use blat to send the ip to my office's mailbox:

blat ip.addr -to xxx -cc xxx -s "ip" -u xxx -pw xxx

Now I'm able to do FTP, VNC, etc. from office to my home!

September 09, 2004 11:39 AM PDT Permalink

Comments:

Post a Comment:

Comments are closed for this entry.

Calendar

« November 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
Today

Links


Navigation


Referers

Today's Page Hits: 15