Where is Home?

  • dyfrin
  • Expert
  • Expert
  • User avatar
  • Posts: 503
  • Loc: WI

Post 3+ Months Ago

Without paying for a static IP what options have you seen besides dyndns services?
I lose my IP every 2 weeks or so with charter.

I am thinking.....
With my sandbox webserver....

Have a webpage that will update the DNS record of the hostname home whenever I visit the page. Then on ff/safari at home, have one of the tabs open up on start to visit that page. The page then modifies the DNS entry of the home host to that current IP.

Then always as long as I use internet at home, the script will update, and then all my pages I use to connect to home like transmission web, etc will be able to be accessed by home.domain.com.

OR instead of using DNS, have a config.php that gets overwritten by visiting the "update" page automatically, and the home.domain.com goes to a page with links that reads ip from the config and appends the ports to access home things.

What do you think?
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6254
  • Loc: Seattle, WA

Post 3+ Months Ago

So I have to ask the obvious question: what's wrong with just using DDNS?
  • dyfrin
  • Expert
  • Expert
  • User avatar
  • Posts: 503
  • Loc: WI

Post 3+ Months Ago

Well, was thinking keeping track of all the ports either requires bookmarks, or on your server a page of links.
Since you are on your server already with option b, why then conform to their domain/hostnames?

The only + dyndns has is the application, but that is also a hinderance imo, I like the least amount of things installed on computers as possible.

Went with the file route, will post code.

Directory structure:
home dir
-index.php
-ip dir
--index.php
--ip.txt


record.php (the get ip and store it)
Code: [ Select ]
<?php
function GetVisitorRealIP()
{
$fwd_ip_string = getenv("HTTP_X_FORWARDED_FOR");
$fwd_ip = "";
if (StrLen($fwd_ip_string))
{
$fwd_ip_list = explode("," , $fwd_ip_string);
$fwd_ip = $fwd_ip_list[0];
}
return $fwd_ip;
}
 
if (getenv(HTTP_X_FORWARDED_FOR))
{
$ip=GetVisitorRealIP;
}
else
{
$ip=getenv(REMOTE_ADDR);
}  
echo($ip);
 
$file = "ip.txt";
$open = fopen($file, "w");
if ($open){
fwrite($open, "$ip");
fclose ($open);
}
else {
    echo('<br /><span style="color: red;">Couldn\'t open file, check that it exists and has 777.</span>');
}
?>
  1. <?php
  2. function GetVisitorRealIP()
  3. {
  4. $fwd_ip_string = getenv("HTTP_X_FORWARDED_FOR");
  5. $fwd_ip = "";
  6. if (StrLen($fwd_ip_string))
  7. {
  8. $fwd_ip_list = explode("," , $fwd_ip_string);
  9. $fwd_ip = $fwd_ip_list[0];
  10. }
  11. return $fwd_ip;
  12. }
  13.  
  14. if (getenv(HTTP_X_FORWARDED_FOR))
  15. {
  16. $ip=GetVisitorRealIP;
  17. }
  18. else
  19. {
  20. $ip=getenv(REMOTE_ADDR);
  21. }  
  22. echo($ip);
  23.  
  24. $file = "ip.txt";
  25. $open = fopen($file, "w");
  26. if ($open){
  27. fwrite($open, "$ip");
  28. fclose ($open);
  29. }
  30. else {
  31.     echo('<br /><span style="color: red;">Couldn\'t open file, check that it exists and has 777.</span>');
  32. }
  33. ?>


index.php (the view results page)
Code: [ Select ]
<?php
$file = ("ip/ip.txt");
if (file_exists($file)) {
}else{
    print "file doesn't exist";
}
$fo = fopen($file, 'r');
$ip = fgets($fo);
fclose($fo);
echo('<a href="http://'.$ip.':9091"><img src="/site/images/transmission.png"></a> <a href="http://'.$ip.':8080"><img src="/site/images/router.png"></a>');
?>
  1. <?php
  2. $file = ("ip/ip.txt");
  3. if (file_exists($file)) {
  4. }else{
  5.     print "file doesn't exist";
  6. }
  7. $fo = fopen($file, 'r');
  8. $ip = fgets($fo);
  9. fclose($fo);
  10. echo('<a href="http://'.$ip.':9091"><img src="/site/images/transmission.png"></a> <a href="http://'.$ip.':8080"><img src="/site/images/router.png"></a>');
  11. ?>

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 4 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.