fedora - Virtualbox host and guest reversed when setting up port forwarding?

08
2014-07
  • Questioner

    In Virtualbox I have a fedora guest and a windows host.

    I was pulling my hair out configuring IP forwarding and I eventually just decided to switch the IP addresses when I noticed the port I was using wasn't being taken up in my windows host.

    (I had host setup as 127.0.0.1; same ports.) I WAS following the response detailed in this question http://stackoverflow.com/questions/9537751/virtualbox-port-forward-from-guest-to-host

    As I said, I switched them--and somehow.. it worked.

    Even though the IP 10.0.2.15 would seem to have no actual meaning to my host machine, that's the configuration that's working.

    I'm running the latest version of VirtualBox. IMO, host and guest would appear to be reversed here, no?

    The important section of the image is the upper left, showing the apparent reversal. Do I have something severely misconfigured? Is the GUI incorrect? Or am I more ignorant than I realize?

    enter image description here

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    windows 7 - SSH from host machine Win7 to guest Fedora Machine in VirtualBox
  • user18151

    I'm using VirtualBox on Windows 7 to run Fedora 7. I seem to have my SSH on, as /sbin/service sshd status tells me. When I do an /sbin/ifconfig, I get this:

    eth0   Link encap:Ethernet  HWaddr 08:00:27:CF:5A:0B
           inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0

    I do an ssh 10.0.2.15 from inside Fedora, and connect back to the guest machine.

    When I do an ipconfig on my Windows machine, I get this information:

    Ethernet adapter VirtualBox Host-Only Network:
    
        Connection-specific DNS Suffix  . :
        Link-local IPv6 Address . . . . . : fe80::b42c:a852:a0e8:1636%19
        IPv4 Address. . . . . . . . . . . : 192.168.56.1
        Subnet Mask . . . . . . . . . . . : 255.255.255.0

    When I now use PuTTY, to connect to 192.168.56.1, it says connection refused. Connection to 10.0.2.15 times out.

    SSH service is running. I have disabled SELinux. Also, I have allowed ssh as a trusted service in system-configure-securitylevel. I have tried to switch the firewall completely, but it turns back on automatically.


  • Related Answers
  • Arjan

    Found the solution. The manual contains it all. Thanks Bender.

    VBoxManage setextradata "Linux Guest"
    "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
    VBoxManage setextradata "Linux Guest"
    "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
    VBoxManage setextradata "Linux Guest"
    "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
  • John T

    I'd suggest not turning off the firewall if your VM has internet access. Try running service network restart (pretty sure it works in Fedora) or simply type ifdown eth0 then ifup eth0. Try connecting to your newly supplied address.

    You could also set it statically for example:

    /sbin/ifconfig eth0 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255

    Give the sshd service a restart too for good measure, then try to connect to 192.168.1.100.

  • nik

    You seem to have a simple networking issue.
    The IP Networks for your two machines are different.
    Try changing your hosted Fedora IP address to 192.168.56.2 and mask 255.255.255.0.

    To confirm this, try to ping from one machine to the other without the changes I suggest above. They should be unreachable both-ways.

  • Joe Internet

    In your VirtualBox settings for your Fedora 7 VM, set the network adapter to "bridged adapter", and choose your primary ethernet card. This will put the VM on the same subnet as your Windows 7 machine, and Fedora should pick up an IP address from your dhcp server. If you're not using dhcp, configure the Fedora 7 adapter (within Fedora) manually.