networking - Access Apache server running in Fedora guest VirtualBox from host
2013-09
I have trouble accessing Apache server from host.
I’ve Fedora 15 VM VirtualBox installed on Windows 7. Within this VM I have Apache server running and working fine within the guest.
Not sure what else I can do to get this working.
Here is the configuration I have. Host OS IP:
IPv4 Address. . . . . . . . . . . : 192.168.0.10
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.2
For VM I've two network adapters installed:
- NAT so that VM machine has access to Internet, it works.
- Host-only adapter.
Here is the configuration on the guest:
[root@localhost network-scripts]# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1394 (1.3 KiB) TX bytes:1394 (1.3 KiB)
p2p1 Link encap:Ethernet HWaddr 08:00:27:DD:DD:EA
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedd:ddea/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1289 errors:0 dropped:0 overruns:0 frame:0
TX packets:1207 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:936406 (914.4 KiB) TX bytes:137003 (133.7 KiB)
p7p1 Link encap:Ethernet HWaddr 08:00:27:44:A3:DB
inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe44:a3db/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:313 errors:0 dropped:0 overruns:0 frame:0
TX packets:386 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:30505 (29.7 KiB) TX bytes:44783 (43.7 KiB)
When I do ping 192.168.56.101
from the host I get proper responses, but all attempts to access web service fail. I get timeout errors.
Typically when ICMP traffic (e.g., ping) is allowed to a virtualized guest but TCP traffic (e.g., HTTP requests) is blocked, the issue is with a software firewall running on the guest OS.
Note: The command syntax syntax in this explanation is Fedora Core specific, but the general steps can be abstracted for use on other distributions of Linux.
Default installations of Fedora Core have IPTables enabled out of the box. Check the status of the IPTables service to see if it is in a 'active' state.
[root@gauss ~]# /bin/systemctl status iptables.service
Additionally, to see the currently active IPTables rules, check the status of IPTables init script.
[root@gauss ~]# /usr/libexec/iptables.init status
If there is a rule an IPTables in the INPUT chain similar to the one included below, it is responsible for blocking both TCP/IP and UDP traffic to the host.
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
There are multiple options regarding how to enable HTTP traffic (e.g., adding an IPTables rule in the INPUT chain to explicitly accept traffic from TCP on port 80 from the hypervisor's host-only network IP 192.168.56.1, removing the universal DROP rule in the INPUT chain, etc.).
Since the guest is not facing the outside world and is on a host-only network, the easiest option is to stop IPTables and disable it so that it will not start automatically upon reboot.
[root@gauss ~]# /bin/systemctl stop iptables.service
[root@gauss ~]# /bin/systemctl disable iptables.service
Once this has been completed, the Fedora Core guest will be able to serve HTTP requests over its public interface and the pages will be viewable on the Windows 7 hypervisor by hitting 192.168.56.101 in a browser or any other HTTP client.
I'm trying to get my FEDORA12 to have an STATIC IP - inside VirtualBox - inside Ubuntu
Let me rephrase that. I have an Ubuntu 9.04 system with VirtualBox and a FEDORA12 VM. I would like to use a static IP on the Fedora VM (amahi needs it), but I'm getting stuck... I'm using NAT (if that's any help)
I tried a few tutorials, but no go.
I'm kind of new to the *nix world but I'm old school on M$
Screenshots:
UBUNTU 9.04 (host that has the VM)
FEDORA
INFO:
GUEST WITH STATIC:
IFCONFIG:
eth0 Link encap:Ethernet HWaddr 08:00:27:35:CC:DE
inet addr:192.168.1.55 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe35:ccde/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:2764 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:574 (574.0 b) TX bytes:127121 (124.1 KiB)
Interrupt:11 Base address:0xc020
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1856 errors:0 dropped:0 overruns:0 frame:0
TX packets:1856 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:181587 (177.3 KiB) TX bytes:181587 (177.3 KiB)
NETSTAT -NR:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.2.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0
GUEST WITH DHCP:
IFCONFIG:
eth0 Link encap:Ethernet HWaddr 08:00:27:35:CC:DE
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe35:ccde/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:105 errors:0 dropped:0 overruns:0 frame:0
TX packets:2966 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:49787 (48.6 KiB) TX bytes:149969 (146.4 KiB)
Interrupt:11 Base address:0xc020
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1903 errors:0 dropped:0 overruns:0 frame:0
TX packets:1903 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:185931 (181.5 KiB) TX bytes:185931 (181.5 KiB)
NETSTAT -NR:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0
PS.: I'm still trying to workout the sudoer file to be able to exec the iptables command
You need your IP address to be on the same subnet as the virtual NAT router. As you can see from when you use DHCP on the guest the subnet is 10.0.2.0/255.255.255.0
, so, when you are setting a static IP address it needs to be in the 10.0.2.x
range. Try setting it to something like 10.0.2.150
. If possible, look in the VirtualBox settings to find the range of IPs the DHCP server will assign so you don't use one of those. Once your on the same subnet, it should work just fine. Just to summarize, here are your settings:
IP: 10.0.2.150
Netmask: 255.255.255.0
Default Gateway: 10.0.2.2