Dynamic hosts file?

Dynamic hosts file?

Other Help — Page [1]
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
I just had an awesome idea, but I have no idea how to go about executing it... or if it can even be done, for that matter.

Basically I want something that will check the IP of the current network I'm in, and depending on the IP have my hosts file change.

Currently I have to manually go in and edit my hosts file every time I enter/leave my home network, in order to access my websites... this is annoying and I want to find an automated way to get aroudn this
 
 
 
2011 Apr 30 at 01:15 UTC
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
Your "websites" ?
Free Steam Games
 
 
 
2011 Apr 30 at 05:49 UTC
SuperJer
Websiteman

2005 Mar 21 • 6666
I would just use fake subdomains.

101.102.103.104 house.example.com
255.254.253.252 work.example.com


And make your site work with both of those.

I think your websites might not really be "WEB" sites if they don't have the same IP in all locations.
 
 
 
2011 May 2 at 20:10 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
superjer said:
I would just use fake subdomains.

101.102.103.104 house.example.com
255.254.253.252 work.example.com


And make your site work with both of those.

I think your websites might not really be "WEB" sites if they don't have the same IP in all locations.

I'm not quite sure what you mean. The IP of my site stays the same regardless of where I am. The problem is that if I put in my WAN IP into my browser, it takes me to the configuration/settings page for my router. The only way (that I know of) to access my site while I'm withing the same network as it, is to use the local IP of my server.

So, as of now I have a line in my hosts file that looks like:
192.168.x.x mysite.com


So, whenever I leave my network, I have to open up the hosts file and comment that line out so I can access it.
 
 
 
2011 May 2 at 21:04 UTC
SuperJer
Websiteman

2005 Mar 21 • 6666
Instead of putting the DNS entry in your hosts file, can you add it on your router? Some routers can do this.

Otherwise, I would change the hosts file entry to

192.168.x.x local.example.com

and then make sure your site will work on that domain as well.
 
 
 
2011 May 2 at 22:07 UTC
phoenix_r

2009 May 13 • 905
17 ₧
What ports are you using? You may be able to forward them, depending on what sort of traffic. Guessing http/https, ports 80/443, maybe some hot ftp action on 21? Alternatively you can change the port(s) server-side to something arbitrary like 69420 and forward that if this isn't something open to the public and/or you don't mind having to use example.com:69420 as the URL.

I'm dumb - can't you just always use the FQDN? Do you not have a registered domain?

Besides this, it seems like you would need to script something that's executed whenever you make a new connection that would look at maybe the MAC of the AP and comment/uncomment based on that.

IDK, ask Kilroy m(*u*)m
BOO
 
 
 
2011 May 5 at 19:19 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
phoenix_r said:

Besides this, it seems like you would need to script something that's executed whenever you make a new connection that would look at maybe the MAC of the AP and comment/uncomment based on that.

IDK, ask Kilroy m(*u*)m


Yeah, I thinking writing some sort of script like that is pretty much the only way I'm gonna get this to work.

Cuz here's what's happening: I go to my domain name, godaddy (who handles my DNS) says "It looks like you're trying to go to rockbombsdomain.com, the IP for that site is xx.xxx.xxx.xx". Then my comp tries to connect to that IP. Only problem is, if I put my own IP into my address bar, it takes me to my router setting page, and as far as I know there's no way to change that in my router (I went through every single option on the router trying to find it xD).

So, either I take the time to write up a program that will do it, or I just deal with it 'til I can afford a new, non-shit router
 
 
 
2011 May 5 at 19:44 UTC
phoenix_r

2009 May 13 • 905
17 ₧
What about changing the port? If you can't change the IP of your router config page it seems unlikely that you'd be able to change just the port, but that would be the easy way. Alternatively you can change the port used for http/s in your server config, forward it in your router, and use rockbomb.com:newport to navigate there. Have you tried something like that yet, or is it a necessity to serve your site on port 80?

Also Supe's subdomain solution seems pretty legit, although I haven't tested that. If it works the way it seems, you could use the subdomain at home and the full domain everywhere else. Have you explored that option?
BOO
 
 
 
2011 May 5 at 21:48 UTC — Ed. 2011 May 5 at 21:50 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
phoenix_r said:
What about changing the port? If you can't change the IP of your router config page it seems unlikely that you'd be able to change just the port, but that would be the easy way. Alternatively you can change the port used for http/s in your server config, forward it in your router, and use rockbomb.com:newport to navigate there. Have you tried something like that yet, or is it a necessity to serve your site on port 80?

Also Supe's subdomain solution seems pretty legit, although I haven't tested that. If it works the way it seems, you could use the subdomain at home and the full domain everywhere else. Have you explored that option?


Well, the problem with the subdomain thing is, the entire site already runs off of a subdomain.
The domain I bought is zard0.us, but everything runs off of the subdomain ha.zard0.us
So... maybe I can do a sub-subdomain?


I'll try messin with the ports when I get home, hopefully that fixes it.
 
 
 
2011 May 5 at 23:27 UTC
SuperJer
Websiteman

2005 Mar 21 • 6666
Either the port or subdomain trick will work fine as long as you don't have code or HTML that cares which port/domain is being used.

And as long as your router doesn't eat traffic to your arbitrary port.

It doesn't have to be a subdomain, either. You could use http://hazard0us/ locally, for example.
 
 
 
2011 May 6 at 00:06 UTC — Ed. 2011 May 6 at 00:07 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
superjer said:
Either the port or subdomain trick will work fine as long as you don't have code or HTML that cares which port/domain is being used.

And as long as your router doesn't eat traffic to your arbitrary port.

It doesn't have to be a subdomain, either. You could use http://hazard0us/ locally, for example.

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOH
I get it now...
Idk why it wasn't clicking with me before, but now I see what you're talking about.
For some reason I thought you were talking about using an actual subdomain that could be reached remotely by everyone, not just one that's created in my hosts file.
Yeah that should definitely work, thanks
 
 
 
2011 May 6 at 02:46 UTC
Page [1]