How do I access the host machine from the guest machine? [closed] - networking

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've just created a new Windows XP VM on my Mac using VMware Fusion. The VM is using NAT to share the host's internet connection.
How do I access a Rails application, which is accessible on the Mac itself using http://localhost:3000?

On the XP machine, find your IP address by going to the command prompt and typing ipconfig. Try replacing the last number with 1 or 2. For example, if your IP address is 192.168.78.128, use http://192.168.78.1:3000.

You can use your host Mac's (or any other Mac on the network) 'local' name:
http://macname.local:3000/
where macname is the network name of your host (or other desired) Mac.

For future visitors: once you've got the IP address figured out, you can add an entry to the Windows hosts file, which is located at C:\Windows\system32\drivers\etc\hosts, to map the IP address to a (virtual) server name. Add a line like this:
192.168.78.1 myrubyapp
Now you can access the site in IE at the address http://myrubyapp:3000
If you use virtual hosts under Apache you'll need this to provide the correct server name.

On the XP machine, Start -> Connect To -> Show all connections.
Double click Local Area Connection.
Click the Support tab.
Take the Default Gateway IP <gateway-ip> and hit http://<gateway-ip>:3000 in your browser.
Gotcha: You must have http:// in the address or IE will give you "The webpage cannot be displayed".

As this question is quite old and referring to XP, here is an alternative for new OSs;
If you're rocking Vista or Windows 7 as the Guest OS, and you have Virtual Hosts setup in the Host via Apache, here's how to setup:
In the Host OS, you need to ensure the network connection is done via NAT;
Right click the network icon in the VM window (bottom-right)
Select "NAT"
Select "Connect"
Wait for the guest OS reconnect to the network
Then, In the Guest OS;
Click Start > Network > Network & Sharing Center
Click "View Status" next to the network connection
Click "Details"
Find "IPv4 Default Gateway"
Open Wordpad
Edit C:\Windows\System32\drivers\etc\hosts
Add a line to the file such as:
[default-gateway-IP] www.example.com
[default-gateway-IP] example.com
Save
Try opening http://www.example.com or http://example.com in IE

For Django it's important to do the following:
./manage.py runserver [default-gateway-IP]:8000
because
https://docs.djangoproject.com/en/dev/ref/django-admin/
Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or 0.0.0.0 or :: (with IPv6 enabled).

I just spent an hour trying to get this to work following the steps on SO but mine ended up being a bit different.
VMWare settings
1.) Set VMWare connection to NAT
2.) run > cmd > ipconfig > copy Default Gateway value
3.) edit hosts file (c:/Windows/System32/drivers/etc/hosts)
add this to your hosts file:
<gateway-ip> yourserver.local
OS X settings
1.) edit Apache config (e.g., sudo vim /etc/apache2/httpd.conf)
add this vhost entry to your httpd.conf file:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "/path/to/your/project"
ServerName yourserver.local
<Directory "/path/to/your/project">
AllowOverride All
Options All
</Directory>
</VirtualHost>
save & quit (:wq)
2.) Edit your hosts file (sudo vim /etc/hosts)
add this line to your hosts file
127.0.0.1 yourserver.local
3.) Restart Apache (sudo apachectl restart)
I found that I had to switch the connection setting on VMWare in order to restart the connection before these settings worked for me. I hope this helps.

Related

How to do port forwarding on VMWare Player 14.1.2 (Ubuntu 18.04 guest, Windows 10 host)?

I have a VMWare Player (14.1.2 build-8497320) running a Ubuntu 18.04 guest on a Windows 10 host. The Ubuntu guest has a LAMP stack that runs a few web applications. I am using NAT to connect the Ubuntu guest to the Windows host's network.
I can access these applications by using the local IP address of the guest (e.g., http://192.168.80.128/mediawiki) from my Windows host. But I want to access it like so from my Windows host: http://localhost/mediawiki. I think this should be possible if I can forward the port 80 of my Ubuntu guest to that of the Windows host.
How do I make this happen please? I don't have access to VMWare Workstation and its Virtual Network Editor.
Edit: I should probably add the motivation for wanting to do this. Basically, I want to avoid figuring out the IP address of the virtual machine everytime I access the web applications.
The (further) reason is that the local IP address of the Ubuntu guest might (I suspect) change, and that will affect quite a few things, such as the base URLs configured in the webapps' configuration files (e.g., the $wgServer variable in LocalSettings.php of MediaWiki).
VMWare Player supports port forwarding over NAT natively:
In the file C:\ProgramData\VMware\vmnetnat.conf put under section [incomingtcp] a line like:
80 = 192.168.80.128:80
Then restart the VMWare NAT Service :
net stop "VMWare NAT Service"
net start "VMWare NAT Service"
Source/credits: https://hitchhikingtheweb.wordpress.com/2014/09/02/portforwarding-with-vmware-player-and-nat/
Also: VMWare documentation of this
You can do it using SSH Tunneling for example.
From windows you open a tunnel from the windows port 80 to the ubuntu port 80.
You can do it using Putty on Windows and having the ssh deamon running on ubuntu, which I guess you should already have.
There are many tutorials on how to do this.
I'll add just one link, but you can always google it and find one that suites you.
Portforwarding with SSH (Putty)
For the possible changes in the guest’s ip:
If you can’t fix the ip in settings then perhaps you can edit the windows hosts file and add a host name for the current Ubuntu ip. Then build the urls using the host name. If the ip changes you change it in the hosts file.

How to setup local domain in local network that everyone can see?

I have a few web-based local applications for home-automation purposes, those are accessible through IP addresses with port numbers something like http://192.168.1.100:8080.
What I am trying to achieve is to link each individual IP and port number combination to an internal domain name, so that anyone can use domain and subdomain names rather than IP addresses.
For example a person can specify a URL of http://kitchen.home rather than an IP address with port number URL such as http://192.168.1.100:8080.
At the same time http://192.168.1.100:8081 could be mapped to a domain name such as hall.home so that a URL of http://hall.home could be used instead of that IP address and port number.
The access to a server should not require having to modify the hosts file of individual PCs but should be some kind of a domain name server that maps domain names to IP address and port number for any PC on the local network.
I have set up a DNS server on a PC running bind9 as a DNS server under Ubuntu 20.04 on my home network in order to have my own special domain names.
A few details about DNS and proxy server with HTTP
To map several different subdomain names within a domain to specific ports on the same PC, you will need a proxy server installed on the the PC as well as a DNS server for the local network. Domain names are mapped to a specific IP address with the DNS protocol and are not mapped to a specific port at the IP address.
In my case I have the same PC hardware with Ubuntu 20.04 that has (1) Bind9 for my DNS server and (2) Apache for my proxy server. I could use two different PCs, one as a DNS server to resolve domain names to IP addresses and the other offering various services accessed either through a single IP port using a proxy server listening on the port to dispatch connections to the services or directly to the service by specifying the correct port number of the desired service.
For example http://kitchen.home/ in a browser would instruct the browser to open a TCP connection to the IP address represented by the domain name kitchen.home using port 80, the default HTTP protocol port. A DNS server is used to resolve the domain name kitchen.home to an IP address. With a URL of http://kitchen.home:8081/, the browser will ask the DNS server to resolve the domain name kitchen.home to an IP address and then open a TCP connection to that IP address but using port 8081 rather than the standard HTTP port 80.
So for http://kitchen.home/ to map to port 8080 at that IP address and for http://hall.home/ to map to port 8081 at that IP address you need to combine a DNS server, which resolves the domain name, with a proxy server residing at port 80, the standard HTTP port. The proxy server will then redirect the request to a different port on the PC selected based on the subdomain name, hall or kitchen, of the entire domain specifier, kitchen.home or hall.home.
See https://stackoverflow.com/a/58122704/1466970 which describes setting up Nginx as a proxy server.
The Apache web server can also serve as a proxy server which is what I'm looking into. See this tutorial from DigitalOcean, How To Use Apache HTTP Server As Reverse-Proxy Using mod_proxy Extension as well as Setting up a basic web proxy in apache.
My environment
I have a Windows 10 PC downstairs with a Ubuntu 20.04 PC upstairs communicating through an Arris router to my cable internet provider. Both PCs are connected to my local home network with WiFi.
The Ubuntu 20.04 PC is my Subversion server using Apache web server. I spend most of my time with the Windows 10 PC downstairs, using PuTTY to connect to the Ubuntu PC with one or more terminal windows when needed. I plan to work with Visual Studio on the Windows 10 PC accessing Subversion through the Apache web server as well as using the Ubuntu PC as a database server (MySQL) and web server (Apache with Php) and microservices (golang and node.js).
I wanted to setup a DNS server on the Ubuntu PC and then point my Windows 10 PC to use the local DNS server for a special domain name while using standard DNS servers such as Google at 8.8.8.8 and 8.8.4.4.
What I did
The procedure I followed was (see How to Configure BIND9 DNS Server on Ubuntu 20.04 and see as well Domain Name Service (DNS) and Everything You Need To Know About Ubuntu DNS Servers):
install bind9 using sudo apt install bind9
create a firewall rule sudo ufw allow Bind9
modify the file /etc/bind/named.conf.options
modify the file /etc/bind/named.conf.local
create a copy of /etc/bind/db.local for my new domain name, home.x
modify the new file, /etc/bind/db.home.x, with the correct rules
The domain name I wanted to use locally was home.x with the idea that if I entered a web site URL of http://www.home.x/ the resulting page would be the Apache web server on my Ubuntu PC. Or if I entered http://home.x/svn the result would be the Subversion repository on my Ubuntu server.
Note: in order for Subversion access through Apache, I had to set that up. See enabling Subversion access via Apache web server and DAV on Ubuntu if you are interested in that.
Details on changes and modified files
The Ubuntu PC has an IP address of 192.168.0.4 on my local network. In the descriptions below, this IP address is used where ever the Ubuntu PC is referenced.
I added a forwarders section to the file /etc/bind/named.conf.options in order to forward any DNS requests that were unknown to my Ubuntu server to some other DNS server. The IP addresses I copied from the list of DNS servers returned by the Window 10 command ipconfig /all which I ran on my Windows 10 PC. The changed file is as follows:
rick#rick-MS-7B98:~/Documents$ cat /etc/bind/named.conf.options
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.
// forwarders {
// 0.0.0.0;
// };
// following forwards are to Google DNS servers at 8.8.8.8 and 8.8.4.4
forwarders {
8.8.8.8;
8.8.4.4;
209.55.27.13;
};
//========================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//========================================================================
dnssec-validation auto;
listen-on-v6 { any; };
};
After changing the file /etc/bind/named.conf.options, I then ran the check utility, which found no errors, and then restarted the bind service.
sudo named-checkconf
sudo systemctl restart bind9
Next I added a new zone directive to the file /etc/bind/named.conf.local to create a DNS entry for my new, local domain name home.x. The modified file looks like:
rick#rick-MS-7B98:~/Documents$ cat /etc/bind/named.conf.local
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "home.x" {
type master;
file "/etc/bind/db.home.x";
};
Finally I needed to create the file /etc/bind/db.home.x specified in the file directive of the zone directive. I did this by starting with a copy of the existing file /etc/bind/db.local by using the command
sudo cp /etc/bind/db.local /etc/bind/db.home.x
I then modified the file /etc/bind/db.home.x in order to specify the rules I needed to resolve the domain name of home.x as well as the subdomain of www.home.x to the IP address of my Ubuntu PC. The modified file looks like:
rick#rick-MS-7B98:~/Documents$ cat /etc/bind/db.home.x
;
; BIND data file for local loopback interface
;
$TTL 604800
# IN SOA home.x. root.home.x. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
# IN NS ns.home.x.
# IN A 192.168.0.4
# IN AAAA ::1
ns IN A 192.168.0.4
www IN A 192.168.0.4
At this point I could test that things worked from my Windows 10 PC by using the nslookup command from a command window. I tried it first without specifying the Ubuntu PC IP address and then with the Ubuntu PC IP address
C:\Users\rickc>nslookup home.x
Server: dns.google
Address: 8.8.8.8
*** dns.google can't find home.x: Non-existent domain
C:\Users\rickc>nslookup home.x 192.168.0.4
Server: UnKnown
Address: 192.168.0.4
Name: home.x
Addresses: ::1
192.168.0.4
I then used the Windows 10 Control Panel (Control Panel > Network and Internet > Network Connections) to see a list of my network adapters in order to modify the DNS server addresses my WiFi adapter was using. This setting is found by doing a right mouse click on the adapter to pop up a floating menu, select Properties to bring up the Properties dialog then select Internet Protocol Version 4 then click the Properties button on the dialog and modify the DNS server address. Below is a screen shot of the dialogs.
After modifying the DNS server address, I retried the nslookup without specifying a DNS server address and the command finds home.x:
C:\Users\rickc>nslookup home.x
Server: UnKnown
Address: 192.168.0.4
Name: home.x
Addresses: ::1
192.168.0.4
When I tested a URL of http://www.home.x/ the test page of my Apache web server is displayed. When I tested a URL of http://home.x/svn the web browser showed the directory tree of my Subversion repository. When I access my Subversion repository with http://home.x/svn/trunk/ within the Ankh Subversion plug-in with Visual Studio 2017 it works.
Other thoughts
One issue with this setup is that if my Ubuntu PC is not up and running then the Windows 10 PC will not have a functioning DNS server until either the Ubuntu PC is brought up or the DNS server address is set back to the original setting on the WiFi adapter. Previously, it was set to discover a DNS server. It may be that I can change this back and from a specified DNS server address, the IP address of my Ubuntu PC, and my Windows 10 PC will discover my Ubuntu PC as a DNS server anyway.
DNS names are independent of port numbers. A dns record correlates a name to an IP address. If you want to omit the port number from urls, you either need to host on the default ports (80/443), or use a proxy.
With a home network, the dns can be tricky, and usually depends greatly on the specific router you have. Your options are basically:
Maybe your router has an interface for defining host overrides. OpenWRT has such a thing, and some routers have a similar dns server on them that you can add host entries to.
Get a public domain name. You can have an A record for example.com that points at a local network address. The server itself may only be accessible inside your network, but the dns will be available anywhere.
Run your own dns server and tell your router to use it as the default resolver for your network.
Maybe mDNS could suit your needs for .local domains.

how to access website hosted on Xampp server through my ip address instead of local host

I've installed xxamp. what i am looking for is i want to access xamp/htdocs/index.php through my IP address not from local host. can any One tell me step by step procedure ? thank you ?
Assuming that xxamp uses Apache (since I've only used wamp) there is configuration file that you can modify: httpd.conf
There should be a line that says "ServerName local host" add a '#' sign in front of it start a new line and type "ServerName (your IP address)" without the quotes and without the parathensis and insert your IP address. I THINK you have to put :80 at the end of your IP.
I did this with wamp, and accessed my files through my tablet and other devices with a router.

Accessing local IP address via a hostname

How can I access a local network IP address (e.g. 192.168.1.91) via a hostname from another machine in the same network (e.g. localhost)?
The reason I want to do this is because my local server running my development application can be accessed from other machines via the IP, however the web app is Dependant on the host name remaining consistent.
You can see where the problem arises when the server is told to fetch images and scripts that rely on the host being localhost and not 192.168.1.91.
I'd suggest that you use localhost only to refer the loopback address (127.0.0.1).
In your case best option would be to register the server in DNS (e.g. test-server.example.com).
If you don't have access to DNS you should be able to use hosts files instead. Just add the following line to your hosts file on all computers that need to access the server:
192.168.1.91 test-server.example.com
hosts file can be found in /etc/hosts in Linux and in %WINDIR%\system32\drivers\etc\hosts in Windows.

Connecting to Windows localhost (IIS) from another computer

I have a Windows Vista laptop running IIS7 for its localhost. On this machine, I can successfully navigate to:
"http://localhost"
"http://127.0.0.1"
"http://mycpuname"
However, I cannot access this localhost website from another computer on the same network. Ideally I would be able to visit "http://mycpuname" (so that I can hard-code a connection), but at this point I might settle for the IP address of the machine (http://192.000.000.xyz)
I've seen similar questions asked here and elsewhere on the internet... but none of the posts seems to fix the issue for me.
Things I've tried:
- adding exceptions to Windows Firewall to allow TCP ports 80 and 8080
- disabling Windows Firewall entirely
- running the "netsh" commands in this post
Additionally, I am looking at the IP address on the Windows laptop by running "ipconfig" from the command prompt. Oddly enough, trying to access "http://192.000.000.xyz" from the Windows laptop doesn't seem to work...
I have also tried restarting IIS and restarting my machine.
Help?
Go to windows firewall with advanced security, inbound rules and check and see if world wide web services is enabled. I had this same issue, and this fixed it for me.
are you binding to 127.0.0.1? run below command
netstat -an |findstr :80 |findstr LISTEN
if it shows 127.0.0.1, you need change IIS listen to 0.0.0.0
Try netstat -na - it will show you what IP addresses your web server is listening on.
If it's only listening on 127.0.0.1, the loopback, you will have to re-configure the web server to listen on all addresses/interfaces (usually either *.*.*.*, or 0.0.0.0 in some config file, or just some drop-down in some windows dialog somewhere).
If, on the other hand, netstat tells you the web server is listening on *.*.*.* or 0.0.0.0, i.e. all interfaces, then you have to figure out what's blocking the traffic - it's either the local firewall, or something on the path between the two computers.
If you want to access your website from any other computer on your local network then you need to simply type your network IP and port. If you want to access it from internet then you need to configure your IP.

Resources