[SOLVED] How to access VM's address from host computer?
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 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.
#
# 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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.