On Dec 21, 2007 6:29 AM, Vitalik N. <[EMAIL PROTECTED]> wrote:
> 1. Yes, there is but it requires some scripting
> 2&3. I don't know any programs that do exactly what you want. So,
> to get your external ip from NATed openbsd box you have to contact some
> external web site (e.g: www.showmyip.com, showip.net and etc). my
> favourite is checkip.dyndns.org since it retuns only one line (excluding
> html header). Here is my implementation on perl: (getmyip.pl)
>
> ----------start--------------------------------------------------
> #!/usr/bin/perl
>
> use Socket;
>
> $port = "80";
> $host = "checkip.dyndns.org";
>
> $iaddr=inet_aton($host);
> $paddr=sockaddr_in($port,$iaddr);
>
> socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
>         or die "Couldn`t create socket : $!\n";
>
> connect(SOCK, $paddr)
>         or die "Couldn`t connect to $host:$port : $!\n";
>
> send(SOCK, "GET / HTTP/1.1\nHost: checkip.dyndns.org\n\n", 0);
>
> @data = <SOCK>;
>
> $html = @data[8];
> if($html =~ m/(\d+.?.\d+.?.\d+.?.\d+)/) {
>         $myip = $1;
> }
> print("$myip\n");
>
> close(SOCK);
>
> -----------end--------------------------------------------------
>
> Yes, you can use cron or you can modify the script above
> so that it hangs in background and checks your ip after some
> interval of time.
>

Using showmyip (or http://dynamic.zoneedit.com/checkip.html, or any
number of others) is guaranteed to work, but it depends on talking to
the outside world--you have to tune your script to make sure showmyip
doesn't start blocking you, and also--if you're paranoid--worry about
MITM attacks. An alternate tactic that a lot of home users with
consumer-boxed routers (e.g. netgear, dlink...) take is to have the
script log in to their router and ask it for the external IP (well,
more often, scrape out the external IP); if your router is under your
full control (i.e. running a standard proper install of linux/BSD)
then it knows it's own external address and you can use that to feed
the dynamic-DNS service.

There's a lot of options.
_______________________________________________
Openbsd-newbies mailing list
[email protected]
http://mailman.theapt.org/listinfo/openbsd-newbies

Reply via email to