Virtualbox "port forward" from Guest to Host [closed] - virtualbox

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
Here is my setup:
- Host: Windows XP
- Guest: Ubuntu 10.04
- Networking: NAT
I am setting an Apache web server on the Guest, but I want to be able to do this on the Windows machine:
- go to the browser, type http://localhost:8000
Also, I tried to change my networking to bridge and I got a new IP. But when I tried to do http://:8000, it says that it could not connect.

Network communication Host -> Guest
Connect to the Guest and find out the ip address:
ifconfig
example of result (ip address is 10.0.2.15):
eth0 Link encap:Ethernet HWaddr 08:00:27:AE:36:99
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
Go to Vbox instance window -> Menu -> Network adapters:
adapter should be NAT
click on "port forwarding"
insert new record (+ icon)
for host ip enter 127.0.0.1, and for guest ip address you got from prev. step (in my case it is 10.0.2.15)
in your case port is 8000 - put it on both, but you can change host port if you prefer
Go to host system and try it in browser:
http://127.0.0.1:8000
or your network ip address (find out on the host machine by running: ipconfig).
Network communication Guest -> Host
In this case port forwarding is not needed, the communication goes over the LAN back to the host.
On the host machine - find out your netw ip address:
ipconfig
example of result:
IP Address. . . . . . . . . . . . : 192.168.5.1
On the guest machine you can communicate directly with the host, e.g. check it with ping:
# ping 192.168.5.1
PING 192.168.5.1 (192.168.5.1) 56(84) bytes of data.
64 bytes from 192.168.5.1: icmp_seq=1 ttl=128 time=2.30 ms
...
Firewall issues?
#Stranger suggested that in some cases it would be necessary to open used port (8000 or whichever is used) in firewall like this (example for ufw firewall, I haven't tested):
sudo ufw allow 8000

That's not possible. localhost always defaults to the loopback device on the local operating system.
As your virtual machine runs its own operating system it has its own loopback device which you cannot access from the outside.
If you want to access it e.g. in a browser, connect to it using the local IP instead:
http://192.168.180.1:8000
This is just an example of course, you can find out the actual IP by issuing an ifconfig command on a shell in the guest operating system.

Related

Not able to connect remote floodlight controller to mininet

I am new to mininet and I was trying to build a mininet topology which uses a remote SDN controller.
I tried using floodlight as the remote controller. I installed it and ran it and it is running on "localhost:6653". But it is also running on 192.168.122.1:6653 (And I have no idea why).
192.168.122.1 is my virbr0 interface's address. In my mininet VM which is in virtualbox i have two network adapters.
NAT
Host only adapter
And for host only adapter i have the following configuration.
Adapter settings:
Ipv4 address: 192.168.56.1 and net mask: 255.255.255.0
DHCP server settings: Sever ip= 192.168.56.100; net mask= 255.255.255.0; Lower bound Ip: 192.168.56.101; Upper bound Ip: 192.168.56.254
To avoid confusion i have added the screenshots as well.
I tried the following command to build my topology:
sudo mn --controller=remote,ip=192.168.122.1,port=6653
I get the following response from mininet
Unable to contact remote controller 192.168.122.1:6653
I have tried changing ip to 192.168.56.1 but that also didn't work.
Any kind of help will be appreciated.
Thanks.
As per your setup, I guess FLC is running on Host OS and mininet is running in Oracle VM.
Your Host-Only network is useful if you are trying to reach something deployed in VM from your Host Os.
It will not work other way around. Here you want to access FLC running on Host inside your VM.
I would suggest using Floodlight VM for Virtual Box. It has mininet and FLC inbuild.
Once imported. Start VM.
Credentials: floodlight/floodlight
Inside VM start FLC
Do ifconfig ithe n terminal and get IP
change to that IP in this
sudo mn --controller=remote,ip=192.168.122.1,port=6653
and execute, all will work fine.
You can access FLC in Host using above IP

Local Server not loading in Ubuntu VirtualBox

I have laravel app which is running in my windows local server. This laravel app is running port:80. I want to load this app in my Ubuntu VirtualBox.
My IP Config:
IPv4 Address : 192.168.8.157
Subnet Mask : 255.255.255.0
Default Gateway: 192.168.8.1
I have config my virtualbox as Bridged Adapter. In my /etc/hosts (ubuntu virtualbox), I have this :
127.0.0.1 localhost
127.0.1.1 asus
192.168.8.157 v2.my.local
I have made a hello word app (node.js) in my local windows which is running on port :3000, and it is running in my VirtualBox by typing v2.my.local:3000, but if I type v2.my.local on my VirtualBox, it is not working (although app is running on windows local machine). it says:
This v2.my.local page can’t be found
Any suggestion? Thanks in Advance.
May be windows firewall blocking connections via port 80. turn off firewall and try it, if it works. Start windows firewall and add firewall rule to allow connections via port 80. If your windows version is 10 then, it will block all virtual box related connections. make sure to add correct rules.

Access rails server from host machine

My rails server (WEBrick 1.3.1) is set on the virtual machine (ubuntu 12.04) and use NAT. The default IP address is 10.0.2.15 with port 3000. How can I access from my host machine (win8) ?
I have tried to use port forwarding but it doesn't work.
Settings -> Network -> Port forwarding
Protocol | Host IP | Host Port | Guest IP | Guest Port
TCP 127.0.0.1 3308 10.0.2.15 3000
By setting your port forwarding as you did, you are telling your host PC that when you visit 127.0.0.1 at port 3308 in your browser, you want that resolved to be your guest virtual machine's I.P. address at port 3000.
With your virtual machine's Rails server running, open a browser on your host PC and navigate to 127.0.0.1:3308.
If your browser doesn't render your guest server's web pages, I'd suspect you have a port conflict (that port 3308 may already be in use). In that case, search for ways to view what ports are currently in use on your PC. Find a port which is not in use and use that in your port forwarding's host port settings.
If anyone faces the same problem, after port forwarding, I resolved this problem running the server binding the ip address of the virtual machine like this:
rails server -b 10.0.2.15

Access django server on virtual Machine

I know there is a lot of similar question but I haven't be able to make it work.
I have a VM (VirtualBox) running CentOS 7
I set up 2 adapters, a NAT and a host-only adapter. This way I have internet output on the VM and I can enter via ssh using a ip (192.168.56.102) from the host
Now, I'm trying to reach a django server running on the guest from the host
I've tried running at 0.0.0.0:8000 and 192.168.56.102:8000 but I always got
$ curl 192.168.56.2:8000
curl: (7) Failed connect to 192.168.56.2:8000; No route to host
I've read some solutions using a bridge instead of NAT, but I need to keep the output to internet and the access via ssh
Finally I opened the port 8000 on the guest firewall and its working now.
For CentOS 7, i followed those steps centos 7 - open firewall port
firewall-cmd --zone=public --add-port=8000/tcp --permanent
firewall-cmd --reload

Why can I connect to http://127.0.0.1:8000/ but not to http://192.168.1.6/

I'm running OS X Mountain Lion on a machine with local IP address 192.168.1.6 (as reported by both the Network utility and ifconfig) and am running a local (Django) development web server on port 8000 that I would like to connect to from a virtual machine running a guest OS on the same machine.
On the host OS (ie, OS X running on the metal of the machine w/ address 192.168.1.6) I can connect to my test web server through the browser by navigating to 127.0.0.1:8000; or localhost:8000; but not when using the machine's local IP address. Here's what makes this extra confusing:
The router is not filtering the ports; and, just to be sure, I've set it to explicitly forward ports 8000 and 22 to 192.168.1.6; And speaking of port 22,
When I start the SSH service, I can connect (from the command line) via ssh 192.168.1.6
It's not a browser issue, because I also can't telnet to 192.168.1.6 port 8000 (connection refused) while I can telnet to 127.0.0.1 port 8000, and I can also telnet to 192.168.1.6 port 22
The firewall is set to off (as reported in System Preferences) but to be extra safe, I've also set an ipfw rule to allow everything through
Here are the ipfw rules:
00100 allow tcp from any to any dst-port 8000
65535 allow ip from any to any
Here is additional confirmation that the port is, indeed, being listened to by my test server:
netstat -an | grep 8000
tcp4 0 0 127.0.0.1.8000 *.* LISTEN
so what's going on here? Somehow port 22 is being treated differently than port 8000, but every place I can think to look for those differences I can't find any. Why can't I get into this machine's port 8000 using its local ip address?
When you start Django development server you need to give the address explicitly:
python manage.py runserver 192.168.1.6:8000
Or if you want the server to run on all interfaces you can use:
python manage.py runserver 0.0.0.0:8000
In other case Django development server defaults to running on the local interface only.
The problem for me was I accidentally quit the server whenever trying to copy the server address. So instead of using ctrl+C just write down the address into your browser.
I solved the issue.There are a few things you might be missing.Listing them below-
1.Once it starts the server, do not press Ctrl+C anyhow .u might be pressing it to copy to url and that accidently closes the server due to which it might be happening.
2.instead of http://127.0.0.1:8000/ ...change the port number to http://127.0.0.1:8080/ ...That would work.
3.Try changing the firewall setting and allow the app.
4.Try opening it with different browsers and incognito too.
The above steps helped solve my issue.Hope they help u too...:)