Route traffic from local network to VirtualBox host-only adapter











up vote
9
down vote

favorite
1












For a test I need to allow routing from my local network to a guest inside a VirtualBox.
The guest already have outside access.



So far I enabled ip forwarding on my local machine (OSX 10.9) and added a route to the host-only network on the machine on the local network.



route add -net 192.168.59.0 netmask 255.255.255.0 gw 192.168.0.107
sysctl -w net.ipv4.ip_forward=1


The network look like that.



Local network 192.168.0.104 -> [Wireless 192.168.0.0/24] -> MacOSX 192.168.0.107 (Wifi) & 192.168.59.3 (VboxHost) -> [VBox 192.168.59/24] -> 192.168.59.103


Unless VirtualBox is purposely dropping packet from the outside this should work.



My goal would be for 192.168.0.104 to connect to 192.168.59.103. So far I can only ping 192.168.59.3 from it.



Also, my guest already have another adapter with a default gw that allow access to the wifi.



What route or network config could I be missing?



Also I could understand the packet getting the my guest, but the guest not being able to reply, however tcpdump show no paquet ever get to guest if say I ping the machine. Also no firewall is running anywhere.



Routing table on my Mac



Destination        Gateway            Flags        Refs      Use   Netif Expire
default 192.168.0.1 UGSc 42 1 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 6 2943735 lo0
169.254 link#4 UCS 0 0 en0
192.168.0 link#4 UCS 3 0 en0
192.168.0.1 9c:d6:43:c8:cf:e8 UHLWIir 43 21647 en0 1199
192.168.0.104 8:0:27:c2:fc:68 UHLWI 0 7 en0 1068
192.168.0.106 0:15:99:77:73:ed UHLWI 0 82 en0 845
192.168.0.107 127.0.0.1 UHS 2 9114 lo0
192.168.59 link#9 UC 3 0 vboxnet
192.168.59.3 a:0:27:0:0:0 UHLWI 0 69759 lo0
192.168.59.103 link#9 UHRLWIi 2 31866 vboxnet 1









share|improve this question




















  • 3




    Any reason you can't just configure your VM's network adapter to be bridged instead of host-only? Your effectively getting the same behavior.
    – heavyd
    Jul 25 '14 at 6:54










  • The same? The host only adapter is separate network, while bridged AFAIK will bind the host to my real network. Which inconvenient because IP while change from office, to home, etc.
    – kkx
    Jul 25 '14 at 14:47










  • I'm a VMware guy but like @heavyd mentioned, you should be able to setup a private or "host only" LAN with Virtual Box just like you can with VMware Fusion or Workstation.
    – SaxDaddy
    Jul 26 '14 at 2:46












  • @SaxDaddy It's exactly that I'm using but trying to route traffic to it for a test. However like I said not working like it should/want (or it's actually doing too good of a job). The host-only adapter seems to be dropping outside traffic, even if the routing is correct or something in MacOSX is no routing the traffic properly.
    – kkx
    Jul 26 '14 at 22:28






  • 4




    I am astounded that no one noticed the error in this configuration, since it is so obvious: in the route add command, the host-only network was configured to use as a gateway a pc outside the host-only network. This cannot possibly work. The correct route should have used as gw the IP address of the mac interface on the host-only adapter, not its default LAN. There are other mistakes (why does lo have an address of 192.168.59.3 in the routing table???) but with the error in route add no progress at all is possible. I leave this note for eventaul readers.
    – MariusMatutiae
    Apr 22 '17 at 8:57

















up vote
9
down vote

favorite
1












For a test I need to allow routing from my local network to a guest inside a VirtualBox.
The guest already have outside access.



So far I enabled ip forwarding on my local machine (OSX 10.9) and added a route to the host-only network on the machine on the local network.



route add -net 192.168.59.0 netmask 255.255.255.0 gw 192.168.0.107
sysctl -w net.ipv4.ip_forward=1


The network look like that.



Local network 192.168.0.104 -> [Wireless 192.168.0.0/24] -> MacOSX 192.168.0.107 (Wifi) & 192.168.59.3 (VboxHost) -> [VBox 192.168.59/24] -> 192.168.59.103


Unless VirtualBox is purposely dropping packet from the outside this should work.



My goal would be for 192.168.0.104 to connect to 192.168.59.103. So far I can only ping 192.168.59.3 from it.



Also, my guest already have another adapter with a default gw that allow access to the wifi.



What route or network config could I be missing?



Also I could understand the packet getting the my guest, but the guest not being able to reply, however tcpdump show no paquet ever get to guest if say I ping the machine. Also no firewall is running anywhere.



Routing table on my Mac



Destination        Gateway            Flags        Refs      Use   Netif Expire
default 192.168.0.1 UGSc 42 1 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 6 2943735 lo0
169.254 link#4 UCS 0 0 en0
192.168.0 link#4 UCS 3 0 en0
192.168.0.1 9c:d6:43:c8:cf:e8 UHLWIir 43 21647 en0 1199
192.168.0.104 8:0:27:c2:fc:68 UHLWI 0 7 en0 1068
192.168.0.106 0:15:99:77:73:ed UHLWI 0 82 en0 845
192.168.0.107 127.0.0.1 UHS 2 9114 lo0
192.168.59 link#9 UC 3 0 vboxnet
192.168.59.3 a:0:27:0:0:0 UHLWI 0 69759 lo0
192.168.59.103 link#9 UHRLWIi 2 31866 vboxnet 1









share|improve this question




















  • 3




    Any reason you can't just configure your VM's network adapter to be bridged instead of host-only? Your effectively getting the same behavior.
    – heavyd
    Jul 25 '14 at 6:54










  • The same? The host only adapter is separate network, while bridged AFAIK will bind the host to my real network. Which inconvenient because IP while change from office, to home, etc.
    – kkx
    Jul 25 '14 at 14:47










  • I'm a VMware guy but like @heavyd mentioned, you should be able to setup a private or "host only" LAN with Virtual Box just like you can with VMware Fusion or Workstation.
    – SaxDaddy
    Jul 26 '14 at 2:46












  • @SaxDaddy It's exactly that I'm using but trying to route traffic to it for a test. However like I said not working like it should/want (or it's actually doing too good of a job). The host-only adapter seems to be dropping outside traffic, even if the routing is correct or something in MacOSX is no routing the traffic properly.
    – kkx
    Jul 26 '14 at 22:28






  • 4




    I am astounded that no one noticed the error in this configuration, since it is so obvious: in the route add command, the host-only network was configured to use as a gateway a pc outside the host-only network. This cannot possibly work. The correct route should have used as gw the IP address of the mac interface on the host-only adapter, not its default LAN. There are other mistakes (why does lo have an address of 192.168.59.3 in the routing table???) but with the error in route add no progress at all is possible. I leave this note for eventaul readers.
    – MariusMatutiae
    Apr 22 '17 at 8:57















up vote
9
down vote

favorite
1









up vote
9
down vote

favorite
1






1





For a test I need to allow routing from my local network to a guest inside a VirtualBox.
The guest already have outside access.



So far I enabled ip forwarding on my local machine (OSX 10.9) and added a route to the host-only network on the machine on the local network.



route add -net 192.168.59.0 netmask 255.255.255.0 gw 192.168.0.107
sysctl -w net.ipv4.ip_forward=1


The network look like that.



Local network 192.168.0.104 -> [Wireless 192.168.0.0/24] -> MacOSX 192.168.0.107 (Wifi) & 192.168.59.3 (VboxHost) -> [VBox 192.168.59/24] -> 192.168.59.103


Unless VirtualBox is purposely dropping packet from the outside this should work.



My goal would be for 192.168.0.104 to connect to 192.168.59.103. So far I can only ping 192.168.59.3 from it.



Also, my guest already have another adapter with a default gw that allow access to the wifi.



What route or network config could I be missing?



Also I could understand the packet getting the my guest, but the guest not being able to reply, however tcpdump show no paquet ever get to guest if say I ping the machine. Also no firewall is running anywhere.



Routing table on my Mac



Destination        Gateway            Flags        Refs      Use   Netif Expire
default 192.168.0.1 UGSc 42 1 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 6 2943735 lo0
169.254 link#4 UCS 0 0 en0
192.168.0 link#4 UCS 3 0 en0
192.168.0.1 9c:d6:43:c8:cf:e8 UHLWIir 43 21647 en0 1199
192.168.0.104 8:0:27:c2:fc:68 UHLWI 0 7 en0 1068
192.168.0.106 0:15:99:77:73:ed UHLWI 0 82 en0 845
192.168.0.107 127.0.0.1 UHS 2 9114 lo0
192.168.59 link#9 UC 3 0 vboxnet
192.168.59.3 a:0:27:0:0:0 UHLWI 0 69759 lo0
192.168.59.103 link#9 UHRLWIi 2 31866 vboxnet 1









share|improve this question















For a test I need to allow routing from my local network to a guest inside a VirtualBox.
The guest already have outside access.



So far I enabled ip forwarding on my local machine (OSX 10.9) and added a route to the host-only network on the machine on the local network.



route add -net 192.168.59.0 netmask 255.255.255.0 gw 192.168.0.107
sysctl -w net.ipv4.ip_forward=1


The network look like that.



Local network 192.168.0.104 -> [Wireless 192.168.0.0/24] -> MacOSX 192.168.0.107 (Wifi) & 192.168.59.3 (VboxHost) -> [VBox 192.168.59/24] -> 192.168.59.103


Unless VirtualBox is purposely dropping packet from the outside this should work.



My goal would be for 192.168.0.104 to connect to 192.168.59.103. So far I can only ping 192.168.59.3 from it.



Also, my guest already have another adapter with a default gw that allow access to the wifi.



What route or network config could I be missing?



Also I could understand the packet getting the my guest, but the guest not being able to reply, however tcpdump show no paquet ever get to guest if say I ping the machine. Also no firewall is running anywhere.



Routing table on my Mac



Destination        Gateway            Flags        Refs      Use   Netif Expire
default 192.168.0.1 UGSc 42 1 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 6 2943735 lo0
169.254 link#4 UCS 0 0 en0
192.168.0 link#4 UCS 3 0 en0
192.168.0.1 9c:d6:43:c8:cf:e8 UHLWIir 43 21647 en0 1199
192.168.0.104 8:0:27:c2:fc:68 UHLWI 0 7 en0 1068
192.168.0.106 0:15:99:77:73:ed UHLWI 0 82 en0 845
192.168.0.107 127.0.0.1 UHS 2 9114 lo0
192.168.59 link#9 UC 3 0 vboxnet
192.168.59.3 a:0:27:0:0:0 UHLWI 0 69759 lo0
192.168.59.103 link#9 UHRLWIi 2 31866 vboxnet 1






macos networking virtualbox






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 30 '14 at 17:51









Geroy290

1052




1052










asked Jul 25 '14 at 2:46









kkx

4612




4612








  • 3




    Any reason you can't just configure your VM's network adapter to be bridged instead of host-only? Your effectively getting the same behavior.
    – heavyd
    Jul 25 '14 at 6:54










  • The same? The host only adapter is separate network, while bridged AFAIK will bind the host to my real network. Which inconvenient because IP while change from office, to home, etc.
    – kkx
    Jul 25 '14 at 14:47










  • I'm a VMware guy but like @heavyd mentioned, you should be able to setup a private or "host only" LAN with Virtual Box just like you can with VMware Fusion or Workstation.
    – SaxDaddy
    Jul 26 '14 at 2:46












  • @SaxDaddy It's exactly that I'm using but trying to route traffic to it for a test. However like I said not working like it should/want (or it's actually doing too good of a job). The host-only adapter seems to be dropping outside traffic, even if the routing is correct or something in MacOSX is no routing the traffic properly.
    – kkx
    Jul 26 '14 at 22:28






  • 4




    I am astounded that no one noticed the error in this configuration, since it is so obvious: in the route add command, the host-only network was configured to use as a gateway a pc outside the host-only network. This cannot possibly work. The correct route should have used as gw the IP address of the mac interface on the host-only adapter, not its default LAN. There are other mistakes (why does lo have an address of 192.168.59.3 in the routing table???) but with the error in route add no progress at all is possible. I leave this note for eventaul readers.
    – MariusMatutiae
    Apr 22 '17 at 8:57
















  • 3




    Any reason you can't just configure your VM's network adapter to be bridged instead of host-only? Your effectively getting the same behavior.
    – heavyd
    Jul 25 '14 at 6:54










  • The same? The host only adapter is separate network, while bridged AFAIK will bind the host to my real network. Which inconvenient because IP while change from office, to home, etc.
    – kkx
    Jul 25 '14 at 14:47










  • I'm a VMware guy but like @heavyd mentioned, you should be able to setup a private or "host only" LAN with Virtual Box just like you can with VMware Fusion or Workstation.
    – SaxDaddy
    Jul 26 '14 at 2:46












  • @SaxDaddy It's exactly that I'm using but trying to route traffic to it for a test. However like I said not working like it should/want (or it's actually doing too good of a job). The host-only adapter seems to be dropping outside traffic, even if the routing is correct or something in MacOSX is no routing the traffic properly.
    – kkx
    Jul 26 '14 at 22:28






  • 4




    I am astounded that no one noticed the error in this configuration, since it is so obvious: in the route add command, the host-only network was configured to use as a gateway a pc outside the host-only network. This cannot possibly work. The correct route should have used as gw the IP address of the mac interface on the host-only adapter, not its default LAN. There are other mistakes (why does lo have an address of 192.168.59.3 in the routing table???) but with the error in route add no progress at all is possible. I leave this note for eventaul readers.
    – MariusMatutiae
    Apr 22 '17 at 8:57










3




3




Any reason you can't just configure your VM's network adapter to be bridged instead of host-only? Your effectively getting the same behavior.
– heavyd
Jul 25 '14 at 6:54




Any reason you can't just configure your VM's network adapter to be bridged instead of host-only? Your effectively getting the same behavior.
– heavyd
Jul 25 '14 at 6:54












The same? The host only adapter is separate network, while bridged AFAIK will bind the host to my real network. Which inconvenient because IP while change from office, to home, etc.
– kkx
Jul 25 '14 at 14:47




The same? The host only adapter is separate network, while bridged AFAIK will bind the host to my real network. Which inconvenient because IP while change from office, to home, etc.
– kkx
Jul 25 '14 at 14:47












I'm a VMware guy but like @heavyd mentioned, you should be able to setup a private or "host only" LAN with Virtual Box just like you can with VMware Fusion or Workstation.
– SaxDaddy
Jul 26 '14 at 2:46






I'm a VMware guy but like @heavyd mentioned, you should be able to setup a private or "host only" LAN with Virtual Box just like you can with VMware Fusion or Workstation.
– SaxDaddy
Jul 26 '14 at 2:46














@SaxDaddy It's exactly that I'm using but trying to route traffic to it for a test. However like I said not working like it should/want (or it's actually doing too good of a job). The host-only adapter seems to be dropping outside traffic, even if the routing is correct or something in MacOSX is no routing the traffic properly.
– kkx
Jul 26 '14 at 22:28




@SaxDaddy It's exactly that I'm using but trying to route traffic to it for a test. However like I said not working like it should/want (or it's actually doing too good of a job). The host-only adapter seems to be dropping outside traffic, even if the routing is correct or something in MacOSX is no routing the traffic properly.
– kkx
Jul 26 '14 at 22:28




4




4




I am astounded that no one noticed the error in this configuration, since it is so obvious: in the route add command, the host-only network was configured to use as a gateway a pc outside the host-only network. This cannot possibly work. The correct route should have used as gw the IP address of the mac interface on the host-only adapter, not its default LAN. There are other mistakes (why does lo have an address of 192.168.59.3 in the routing table???) but with the error in route add no progress at all is possible. I leave this note for eventaul readers.
– MariusMatutiae
Apr 22 '17 at 8:57






I am astounded that no one noticed the error in this configuration, since it is so obvious: in the route add command, the host-only network was configured to use as a gateway a pc outside the host-only network. This cannot possibly work. The correct route should have used as gw the IP address of the mac interface on the host-only adapter, not its default LAN. There are other mistakes (why does lo have an address of 192.168.59.3 in the routing table???) but with the error in route add no progress at all is possible. I leave this note for eventaul readers.
– MariusMatutiae
Apr 22 '17 at 8:57












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Host-only networking mode cannot be used to route traffic from the local network to the VM hosts. You should use use Bridged, NAT or NAT network. With the last two you need a port-forward.



References:



[1] https://www.virtualbox.org/manual/ch06.html#networkingmodes (See the table at the end of section 6.2)
[2] https://www.virtualbox.org/manual/ch06.html#network_hostonly






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f787797%2froute-traffic-from-local-network-to-virtualbox-host-only-adapter%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Host-only networking mode cannot be used to route traffic from the local network to the VM hosts. You should use use Bridged, NAT or NAT network. With the last two you need a port-forward.



    References:



    [1] https://www.virtualbox.org/manual/ch06.html#networkingmodes (See the table at the end of section 6.2)
    [2] https://www.virtualbox.org/manual/ch06.html#network_hostonly






    share|improve this answer

























      up vote
      0
      down vote













      Host-only networking mode cannot be used to route traffic from the local network to the VM hosts. You should use use Bridged, NAT or NAT network. With the last two you need a port-forward.



      References:



      [1] https://www.virtualbox.org/manual/ch06.html#networkingmodes (See the table at the end of section 6.2)
      [2] https://www.virtualbox.org/manual/ch06.html#network_hostonly






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Host-only networking mode cannot be used to route traffic from the local network to the VM hosts. You should use use Bridged, NAT or NAT network. With the last two you need a port-forward.



        References:



        [1] https://www.virtualbox.org/manual/ch06.html#networkingmodes (See the table at the end of section 6.2)
        [2] https://www.virtualbox.org/manual/ch06.html#network_hostonly






        share|improve this answer












        Host-only networking mode cannot be used to route traffic from the local network to the VM hosts. You should use use Bridged, NAT or NAT network. With the last two you need a port-forward.



        References:



        [1] https://www.virtualbox.org/manual/ch06.html#networkingmodes (See the table at the end of section 6.2)
        [2] https://www.virtualbox.org/manual/ch06.html#network_hostonly







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 28 at 20:29









        Marcelo Roberto Jimenez

        445




        445






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f787797%2froute-traffic-from-local-network-to-virtualbox-host-only-adapter%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]