Is there a way to replace 127.0.0.1 on my local machine for test purposes? - networking

I know it may sound stupid but anyway. Maybe there is a trick?
I just want that the local web server receives requests from my local machine but somehow sees a different IP address? Even one single that is different from the infamous 127.0.0.1 would of a great assistance.
Are there any options available?

Try 127.0.0.2 or 127.0.0.3 ... or ...
Seriously, try it!
Depending on your operating system, localhost might be reachable via the entire 127.0.0.0/8 network, so even 127.42.37.254 would reach localhost (it does on my Ubuntu machine).

Or put an entry in your HOSTS file for anything you want, pointing to localhost.

Are you accessing the local web server via 127.0.0.1? If so, what if you use your machine's actual IP address? The request will still end up at your local web server, but maybe it will see that as the sender instead of 127.0.0.1.

You could use your public IP address.

You can always configure webserver to listen on your network ip address and then use that ip.
On the other hand if you are looking to get requests from multiple domains like a.localhost, b.localhost, and c.localhost try editing your hosts file to redirect domains to 127.0.0.1

Related

Plumber R, changing 'localhost' to local machine IP as test

I have an R script which is outputs values through an API using Plumber, all runs fine on my local machine (windows 10) when using a 127.0.0.1 or localhost address in the browser, but if I change to use my machines actual IP the browser throws a 'refused to connect' error( I'm running this as a test, before moving everything onto a networked server). Any ideas if this should work? the literature seems to suggest it should...or any tips on what might be preventing this from working?
thanks
You need to replace the 127.0.0.1 by 0.0.0.0 to make your api accessible by your machine ip.
library(plumber)
r <- plumb("api.R")
r$run(host = "0.0.0.0", port = 8000)
You likely have a firewall configured on your machine that is preventing "external" access on your IP address. You'd need to open up a port in your local firewall in order to allow traffic in, but you're probably better off just deploying to an external server so you don't have to start poking holes in your machine's firewall (a real security concern) just as an experiment.
Also keep in mind that "the machine's actual IP address" can be a little ambiguous. If that's the IP on your local network (for example, 192.168..., or 172.16...) then it's probably your machine's firewall like I mentioned above. But if you're using a residential computer and trying to access on your public IP, then there is more networking equipment involved (like your router) that would need to be configured.
All that to say, you're probably going to have an easier time just spinning up a DigitalOcean server and trying to run it there (see plumber's do_provision function) as you won't have to worry about any of these issues there.

How to change a port on a server into a different IP address in centos 7

I've got a few web servers running on my local network and, I wanted to change a specific port on a web server into IP address so that I can easily proxy them over nginx and also have access to them locally via Bind. I've got a server [HTTPD] with a few WordPress sites running on different ports [i.e 80, 8080 ETC] and I would like to change those into a private IP address locally. This is a complicated problem of the fact that I cannot specify port numbers on my local DNS, and I also don't want to install another nginx server on the local sites. Thanks guys
Search the web for "Centos 7 IP Aliasing" and set up a new IP address that connects to your machine. Then configure a new virtual host to listen on that new IP address.
I would give you more info, except A) IP aliasing on Centos 7 is more involved than I like (much easier on Solaris), and B) I'm not familiar at all with configuring Nginx (very easy on Apache).
#Tarun Lalwani asks a good question regarding whether this is a home or local network vs. a public one. You have to pay $$ for a public IP address as they are a scarce, managed resource, whereas your local network can accommodate almost as many IP's as you can think of. Anyone on your local network can access your service on your machine using those extra IP's. However, accessing those local IP's from the Public Internet is a separate topic altogether, involving router configurations and NAT addressing.
It may not be the precise answer you're looking for, but at least it should give you a direction to continue looking.

HttpListener working on local network, but not externally

I am attempting to spin up an application that listens on a port and responds to HTTP requests. I am on a Windows 8 machine connecting through a Netgear router that provides port forwarding. I have:
modified my DNS zone file of one of my domains to point to the IP address that is assigned to my cable modem
Added a port-forwarding rule to my router that sends requests to port 8080 to port 8081 on my computer
Opened port 8081 on my Windows Firewall
Executed netsh http add urlact http://+:8081/ user=Everyone listen=yes as administrator
Started up my app which uses the simple webserver solution found at http://codehosting.net/blog/BlogEngine/post/Simple-C-Web-Server.aspx which uses an HttpListener object with a prefix of http://+:8081/.
From any machine on my local network, I can browse to http://home.example.com:8080/blah/blah and everything works great. Whenever I attempt the same URL from a machine connected elsewhere on the Internet, the connection times out. I have tried using the IP address instead the domain name, and have tried disabling my Windows Firewall (temporarily), still with no luck.
I'm sure this is more of a network setup issue than a code issue, but I thought I would ask anyway to see if there is anything I can do. Sorry for the spaces in the urls above. This is my first post to SO, and I apparently don't have enough of a reputation to post more than a single link.
By "elsewhere on the Internet", I am assuming you are attempting to access it from a different ISP.
The thing about some ISPs is that unless you are paying for a "business class" connection, they will do all sorts of tricks to ensure that you remain a "consumer". What you need is an unNATed static IP address.
By this I mean that the IP address that you may have at your home may not be accessible to the outside world because the ISP is actually NATing (or other) that address to you. This is a fairly common practice because of limited IP4 addresses. If you really want a service accessible via the WWW, I would suggest moving your product to a VPN, or at least a commodity hosting provider.
Edit: Try a VPN service like Hamachi

Access website over local network from other devices?

I have a website that I'm running locally at localhost:8000. I'd like to access my site from other devices on my network. I've tried to visit the site via my computer's internal IP address via: 127.0.0.1:8000but this doesn't work. Is this possible?
Three most probable things:
Check if there is a network route between the client and the server machine (commands like PING and TRACERT will help);
Check if the server machine has a firewall. If it does, there must be a rule allowing (opening) connections through that port (8000) in TCP;
Most likely, the problem is one of the two above. If not, there's one last thing:
Make sure the web server (the one that serves localhost:8000) is bound to listen to all IP addresses (not only 127.0.0.1).
To know that, search for servername bind all ip addresses on google. E.g., for apache HTTPD, it'd be apache bind all ip addresses.
here is what I do in similar cases:
search rejetto hfs on google, it is single executable less than 1Mb size and download it into your server machine.
after starting it, follow menu->IP addresses. these are all your possible addresess on the server side.
these are your IP addresses to enter, and your port is 8000 as you mentioned.
most possible IP addresses you will find are in the format of following:
192.168.?.?
10.0.0.?
169.254.?.?
besided you will probably need to add a firewall rule for your server app.

Allow user from another PC to connect to my localhost website

I am running a website on localhost:portnumber on visual studio 2005, and want to allow another person to connect to it from another PC. Is this possible?
You can try following this article and see if it works
http://www.pluralsight-training.net/community/blogs/jimw/archive/2009/09/03/accessing-the-visual-studio-asp-net-development-server-from-iphone.aspx
Possible, yes.
You will need an ip address that is accessible from that other machine.
Your firewall will need to allow the appropriate port to be open (typically 80).
If you want them to use a DNS name, that DNS name must be pointed to your IP. And, again, it must be externally accessible.
Now, if the client is NOT on your local network, then the IP will have to be a public one that is routed to your machine. Depending on where you are (corporate, etc) there may be other firewalls in place to prevent this. In this case contact your local network admin.
Yes its possible for only for testing purposes first you need to install IIS and get dynamic DNS to allow user to connect to your computer (Using your Dynamic IP) Check No-IP , dyndns point this dynamic host to your IIS website, Bindings settings
Yes, it is possible. You need to do two things:
1) Open that "portnumber" for incoming connections through your windows firewall (and any other firewall you may be running).
2) Set up your router to allow incoming connections on that "portnumber" and route those connections to your local computer's IP Address.
That should do it. Be aware that doing this opens up your computer to be hacked if you are not careful.

Resources