LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-08-2016, 08:34 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
How to access VM's address from host computer?


How to access VM's address from host computer?
Scenario:

Hostname: LinuxMint

Quote:
Virtual machine: KVM, CentOS7
#Look at address on interface of VM
[user1@localhost html]$ ifconfig
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.122.216 netmask 255.255.255.0 broadcast 192.168.122.255
I have installed httpd.
From within the CentOS7 VM, I am able to display index.html in Firefox using url http://localhost or http://192.168.122.216/


Quote:
# I am also able to ping http://192.168.122.216/ from the host to VM.
LinuxMint $ ping 192.168.122.216
PING 192.168.122.216 (192.168.122.216) 56(84) bytes of data.
64 bytes from 192.168.122.216: icmp_seq=1 ttl=64 time=0.792 ms
64 bytes from 192.168.122.216: icmp_seq=2 ttl=64 time=0.613 ms
... ...
But I cannot display the webpage index.html from LinuxMint host (not from the CentOS VM) using Firefox, using url http://http://192.168.122.216/

I can ping the VM's address from host, but not display its web page.
Why?
Is there a way to do this?

Alternatively, if my host IP address is 192.168.0.14,
I can ping it also from the VM's side:
But not able to access index.html on host side with Firefox via http://192.168.0.14.
 
Old 08-08-2016, 08:38 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,321
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
A couple of questions for starters:

Is port 80 open to external calls in the VM? (That's the default port for www.)

Can you ssh into the VM?
 
Old 08-08-2016, 08:54 PM   #3
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
@frankbell:

Here is the address : port setting in httpd.conf:
Quote:
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
#Listen 80 # this did not work earlier
Listen 192.168.122.216:80
Still not able to access VM's index.html from host side.
 
Old 08-08-2016, 11:38 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Run
Code:
iptables -nvL
on VM to chk firewall.

Also
Code:
netstat -tanp
also on VM to chk httpd IS listening
 
Old 08-08-2016, 11:51 PM   #5
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
I am using CentOS7, and firewalld is running.
So I cannot run iptables due to conflicts.

Quote:
[user1@localhost ~]$ netstat -tanp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.216:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
... ...
Quote:
[user1@localhost ~]$ firewall-cmd --get-active-zones
public
interfaces: ens3
[user1@localhost ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
... ...
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:d4:63:70 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.216/24 brd 192.168.122.255 scope global dynamic ens3
valid_lft 2520sec preferred_lft 2520sec
inet6 fe80::5054:ff:fed4:6370/64 scope link
valid_lft forever preferred_lft forever
As you can see tcp is listening on 192.168.122.216 : 80.
And the address corresponds to interface inet 192.168.122.216/24.

Last edited by fanoflq; 08-08-2016 at 11:52 PM.
 
Old 08-08-2016, 11:53 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
well, use whatever C7 cmd is equiv; you need to chk if firewall is open...
 
1 members found this post helpful.
Old 08-09-2016, 12:53 AM   #7
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
@chrism01:

Thanks.
I turned off firewalld on port, and it worked.

Quote:
firewall-cmd --zone=public --add-port=80/tcp
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Address maps to host, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT! NotionCommotion Linux - Newbie 3 03-08-2016 01:42 AM
convert LAN IP address to Host Name when I give cmd tail -f /var/log/squid/access.log rs15 Linux - Networking 6 01-22-2012 01:45 AM
Convert guest logical address to host physical address hmd429 Linux - Virtualization and Cloud 1 10-07-2011 03:44 AM
Convert guest logical address to host physical address hmd429 Linux - Kernel 0 10-07-2011 02:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration