I have Apache2 running on one of my linux machines, and I often use it to browse a local website on that machine from other machines on my home network.
But I can only do so by accessing the server by IP address.
I would like to be able to access via hostname, or some other arbitrary, memorable string, but I can't figure out how to do this. My Netgear router has a section that lists MAC addresses, corresponding IP addresses (assigned by the router through DHCP) and a user-configurable device name. I thought this would map between the device name and IP address, but it doesn't; all attempts to load a webpage using the device name fail, although the page loads just fine if I provide the IP address directly.
How do I make this happen? I'm running Linux on the server machine.
Basically you will need to run a name server on a machine on your network and make it auth for your local domain. Then adjust your Dhcp server to give out that server as the DNS server. Or you coukd always modify your hosts file on your boxes to contain the name to ip mappings if you don't have a lot of hosts.
Related
I've developed a small application to manage grocery using Node.js and Express, and I run it locally on my pc. There are other three computers in my home: all four computers are connected to my wi-fi and need to access to my grocery application.
In this scenario, my computer acts as a "server": the other three connect to mine using my IP and the port I've set in Node.js (eg: to access in my application I type in my browser "http://localhost:3000/", while from the other three computers it's something like "http://192.168.x.x:3000/").
My problem is the following: since I'm connected to wifi, I found that my IP address often changes, so everytime this happens I have to look for my address (using ipconfig) and manually update the bookmarks saved in the other computers. I was wondering if there is a program / method / script / something that I could do to give my computer some sort of "local url" or something similar to a "local DNS", a name that can be used to find my pc in the WLAN. I've already tried to set my wi-fi router in order to have static IPs but for some reason that doesn't work well with my internet connection, so I was hoping for a different solution.
Thanks for your help!
While some smart routers have DNS capabilities, my experience is that most home routers do not. This solution can work without built in DNS capabilities for your router, and while it is not exactly 'DNS' it should keep you from having to reset the bookmarks on the other computers. Depending on your router, you should be able to adjust the DHCP range of IP addresses that it can assign to devices. You can set it to a smaller range of addresses, and assign your host computer a static address, so it doesn't change.
For example, lets say your network is using 192.168.0.x/24 addresses. So the router by default will most likely assign IP addresses in a range from 192.168.0.2 (the router is usually 192.168.0.1) to 192.168.0.254. You could adjust the DHCP range in your router settings to assign an IP address range from 192.168.0.1 to 192.168.0.250, and then manually set your host computer's address to 192.168.0.251. On all the other computers, you can now set the bookmarks to 192.168.0.251, and you shouldn't have to change them. You could also edit the hosts file (on Windows machines) so it maps an internal domain name, such as groceries.com, to your host machine, 192.168.0.250. To change the hosts file, go to C:\Windows\System32\drivers\etc, then open the hosts file in notepad, and enter in the desired domain name and IP address. Once the hosts file has been edited on all the client computers, you can just use groceries.com as the url from any browser on the computer
here's a link for manually setting the IP address on a Windows 10 PC
https://support.microsoft.com/en-us/help/15089/windows-change-tcp-ip-settings
I have setup a number services on my home network (two security system DVR's and IIS on my Windows 7 machine).
All of these devices are behind two routers and have static IP's. I have configured port forwarding on both routers so that everything is accessible via my public IP address. When querying my public IP address outside from a machine outside of my local networ, everything is 100% accessible and working as expected. However, when querying my public IP from a machine or device on my local network, the requests just timeout with nothing served. The only way I can access these resources from a machine on my local network is by querying them by their local IP address.
To explain more clearly (using example IP's):
My Windows 7 machine (which has IIS setup, accessible over port 80) has a local IP of 192.168.1.100
My first security system DVR has a local IP of 192.168.1.101 and is accessible over port 5000
My second security system DVR has a local IP of 192.168.1.102 and is accessible over port 5001
My public (static) IP address is 222.222.222.222
When I am outside of my local network and I open http://222.222.222.222/ in my browser, my Windows 7 IIS website appears in my browser. When I am outside of my local network and I open http://222.222.222.222:5000/ in my browser, my first security system appears in my browser. Lastly, when I am outside of my local network and I open http://222.222.222.222:5001/ in my browser, my second security system appears in my browser.
However, when I am on my local network, I am unable to load any of these devices using my external IP address. The requests just timeout with nothing loaded. When I am on my local network the only way I can get these to load in my browser is by browsing directly to their local IP addresses in my browser.
I'm guessing that I somehow need to either A: get my request for my public IP when on my local network be first sent outside my local network and then sent back to it through my public IP or B: somehow detect if the public IP address is being queried from a local IP and if so, serve up those resources via their local IP...however I don't know if either of those are correct, and even if they are, I don't know how I'd go about doing it.
Can anybody point me in the right direction? All the machines on my local network I'd like to access these resources from are Windows 7 machines, if that makes a difference.
Ideally, you could utilize NAT loopback if your router(s) supports it. NAT Loopback Wiki
If your routers don't support NAT loopback, you may have to go with option B (better than A). Assuming you only need this functionality from one PC, you could mess with the routing tables. That would get really messy in Windows, but possible. AND you would have to track your dynamically changing external IP address somehow. I'll leave options A and B at "improbable" but I'd love for the community to prove me wrong =)
This might be a stupid question, but i run a business in a strip mall and internet is included (because of this I have no access to the router). the router assigns dynamic ip address and when I set a static ip I lose connection.
is there a way to change the address to my node app from "http:/ /[my-server-ip]:3000" to something like "http:/ /[business-name]:3000". (/ / should be // but stack wont let me post with dead links)
the main reason for this is I have multiple tablets and devices that use this system however recently after they made some changes to the routers setting my computer will be assigned two or three ip addresses a day (I notified the landlord he says its normal). and everytime my ip address changes I lose connection to my app.
is there a possible fix that doesnt require me to host on a web server or enable port forwarding?
perhaps I should reword the question. How do I go about setting up local dns zones from mac? (I know this can be achieved with most linux distros)
No you can't.
Your server IP will always change as the router gives you a new IP address, so change the hosts will not work unless every time the ip on the server changes, you change your ip as well on the devices.
You may try to create an account on dns sites like http://www.noip.com/. They will give you an "external" internet address like mybusiness.noip.com and then you will point your programs on tablets and cell phones to this address.
You will then install a program on your server that will tell noip what the new address is maintaining the same mybusiness.noip.com on them.
I have a PC at my home that I typically access using Remote Desktop. I would like to be able to use a domain name to access this computer, and be able to use the same domain name regardless of if I am at home (on the same network as that PC) or on the road.
I know that I need to use Dynamic DNS in order to keep my IP address up to date. I have that working now.
I also have port forwarding configured on my router to send traffic on the ports I'm using to that PC's local IP address.
I am able to successfully get to my computer from the outside world using mypc.mysite.com (example url).
However, when I am at home, the mypc.mysite.com domain name needs to resolve to the local IP address, and instead it is getting my "outgoing ip".
I know I can get around this my modifying the "host headers" on my PC, but I want it to work on other devices like my tablet. I also don't want to have to switch my host header file every time I boot depending on where I'm at.
Does anyone have a suggestion?
Hi I have a Huawei ADSL modem with a dynamic IP. I set up a dynamic dns with freedns and I can easily access my Virtual host on apache from outside my private network, from internet.
So trying to access it from a local network I get a modems login page.
I have the rule in my modems NAT to connect port 80 to my server but it seems it doesnt work from internal net.
My server hosting the virtual host is 192.168.0.1 , the modem has the 192.168.0.254 address.
I tried to put my external domain name into the /etc/hosts file, but if I do that then asterisk server gets confused.
What could be the cause of the problem ? And what would be the best solution to this problem ?
Should I set up a caching DNS on the private side of the net ?
Hugger is half right... Its because your router is blocking loopbacks. The easiest way around this is to edit the hosts file (See the Wiki page) on the computer that is behind the network to see the local IP of the computer as the virtual host your going for. For example if your server is on 192.168.0.1 and the virtual hostname is www.imrad.com then insert
192.168.0.1 www.imrad.com
into your hosts file. If your computer leaves the local network (like a laptop you take to work) and joins a network not behind your router you need to comment out the line in the hosts file.
well actually to access that you must find the local ip address of the server by going into command line/prompt and typing ipconfig /all then you will find ipv4 address. Take note of that.
Go to another computer and your that ip and it will show.
The reason that was happening is because the router/modem knows you are in its network so it will think you ar trying to go top the login page of it. That happens to me too.