Virtualbox NAT Network port forwarding refuses connection












0















I created a NAT Network in VirtualBox and from the Ubuntu host I am trying to SSH into the Ubuntu server VM, but I get connection refused. The Ubuntu server VM is connected to the NAT Network using port forwarding. I can connect successfully with port forwarding if I set NAT instead of NAT Network in the adapter, but for this assignment I have to use NAT Network.



Can anybody help? I have already spent many hours trying to solve this. I think the problem might be with the Ubuntu host and not with VirtualBox, but still can't figure out the solution.



Host: Ubuntu 18.04.1. LTS



VirtualBox: 5.2.18_Ubuntu r123745



Guest: ubuntu-16.04.5-server-i386



Guest Network Settings:



guest machine network adapter



NAT Network:



NAT Network settings



Port Forwarding Rules:



port forwarding rules



Guest Network Interfaces:



output of ifconfig on guest VM



Failing SSH connection



root@ThinkPad:~# ssh -vvv user@127.0.0.1 -p 1022
OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "127.0.0.1" port 1022
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 1022.
debug1: connect to address 127.0.0.1 port 1022: Connection refused
ssh: connect to host 127.0.0.1 port 1022: Connection refused


Update




  • I have changed the entry port for the forwarding from 1022 to 10001, because with port 1022 forwarding wasn't working with NAT either.

  • When I use port 10001 for forwarding, I can see the on the host VirtualBox is actually listening on that port:


root@giacomo-ThinkPad:~# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:10001 0.0.0.0:* LISTEN 2482/VirtualBox
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1489/dnsmasq


Instead when using the same forwarding rules with NAT Network, VirtualBox is not listening. So it looks like the problem might be in VirtualBox?










share|improve this question





























    0















    I created a NAT Network in VirtualBox and from the Ubuntu host I am trying to SSH into the Ubuntu server VM, but I get connection refused. The Ubuntu server VM is connected to the NAT Network using port forwarding. I can connect successfully with port forwarding if I set NAT instead of NAT Network in the adapter, but for this assignment I have to use NAT Network.



    Can anybody help? I have already spent many hours trying to solve this. I think the problem might be with the Ubuntu host and not with VirtualBox, but still can't figure out the solution.



    Host: Ubuntu 18.04.1. LTS



    VirtualBox: 5.2.18_Ubuntu r123745



    Guest: ubuntu-16.04.5-server-i386



    Guest Network Settings:



    guest machine network adapter



    NAT Network:



    NAT Network settings



    Port Forwarding Rules:



    port forwarding rules



    Guest Network Interfaces:



    output of ifconfig on guest VM



    Failing SSH connection



    root@ThinkPad:~# ssh -vvv user@127.0.0.1 -p 1022
    OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n 7 Dec 2017
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug2: resolving "127.0.0.1" port 1022
    debug2: ssh_connect_direct: needpriv 0
    debug1: Connecting to 127.0.0.1 [127.0.0.1] port 1022.
    debug1: connect to address 127.0.0.1 port 1022: Connection refused
    ssh: connect to host 127.0.0.1 port 1022: Connection refused


    Update




    • I have changed the entry port for the forwarding from 1022 to 10001, because with port 1022 forwarding wasn't working with NAT either.

    • When I use port 10001 for forwarding, I can see the on the host VirtualBox is actually listening on that port:


    root@giacomo-ThinkPad:~# netstat -tulpn
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    tcp 0 0 0.0.0.0:10001 0.0.0.0:* LISTEN 2482/VirtualBox
    tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1489/dnsmasq


    Instead when using the same forwarding rules with NAT Network, VirtualBox is not listening. So it looks like the problem might be in VirtualBox?










    share|improve this question



























      0












      0








      0








      I created a NAT Network in VirtualBox and from the Ubuntu host I am trying to SSH into the Ubuntu server VM, but I get connection refused. The Ubuntu server VM is connected to the NAT Network using port forwarding. I can connect successfully with port forwarding if I set NAT instead of NAT Network in the adapter, but for this assignment I have to use NAT Network.



      Can anybody help? I have already spent many hours trying to solve this. I think the problem might be with the Ubuntu host and not with VirtualBox, but still can't figure out the solution.



      Host: Ubuntu 18.04.1. LTS



      VirtualBox: 5.2.18_Ubuntu r123745



      Guest: ubuntu-16.04.5-server-i386



      Guest Network Settings:



      guest machine network adapter



      NAT Network:



      NAT Network settings



      Port Forwarding Rules:



      port forwarding rules



      Guest Network Interfaces:



      output of ifconfig on guest VM



      Failing SSH connection



      root@ThinkPad:~# ssh -vvv user@127.0.0.1 -p 1022
      OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n 7 Dec 2017
      debug1: Reading configuration data /etc/ssh/ssh_config
      debug1: /etc/ssh/ssh_config line 19: Applying options for *
      debug2: resolving "127.0.0.1" port 1022
      debug2: ssh_connect_direct: needpriv 0
      debug1: Connecting to 127.0.0.1 [127.0.0.1] port 1022.
      debug1: connect to address 127.0.0.1 port 1022: Connection refused
      ssh: connect to host 127.0.0.1 port 1022: Connection refused


      Update




      • I have changed the entry port for the forwarding from 1022 to 10001, because with port 1022 forwarding wasn't working with NAT either.

      • When I use port 10001 for forwarding, I can see the on the host VirtualBox is actually listening on that port:


      root@giacomo-ThinkPad:~# netstat -tulpn
      Active Internet connections (only servers)
      Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
      tcp 0 0 0.0.0.0:10001 0.0.0.0:* LISTEN 2482/VirtualBox
      tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1489/dnsmasq


      Instead when using the same forwarding rules with NAT Network, VirtualBox is not listening. So it looks like the problem might be in VirtualBox?










      share|improve this question
















      I created a NAT Network in VirtualBox and from the Ubuntu host I am trying to SSH into the Ubuntu server VM, but I get connection refused. The Ubuntu server VM is connected to the NAT Network using port forwarding. I can connect successfully with port forwarding if I set NAT instead of NAT Network in the adapter, but for this assignment I have to use NAT Network.



      Can anybody help? I have already spent many hours trying to solve this. I think the problem might be with the Ubuntu host and not with VirtualBox, but still can't figure out the solution.



      Host: Ubuntu 18.04.1. LTS



      VirtualBox: 5.2.18_Ubuntu r123745



      Guest: ubuntu-16.04.5-server-i386



      Guest Network Settings:



      guest machine network adapter



      NAT Network:



      NAT Network settings



      Port Forwarding Rules:



      port forwarding rules



      Guest Network Interfaces:



      output of ifconfig on guest VM



      Failing SSH connection



      root@ThinkPad:~# ssh -vvv user@127.0.0.1 -p 1022
      OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n 7 Dec 2017
      debug1: Reading configuration data /etc/ssh/ssh_config
      debug1: /etc/ssh/ssh_config line 19: Applying options for *
      debug2: resolving "127.0.0.1" port 1022
      debug2: ssh_connect_direct: needpriv 0
      debug1: Connecting to 127.0.0.1 [127.0.0.1] port 1022.
      debug1: connect to address 127.0.0.1 port 1022: Connection refused
      ssh: connect to host 127.0.0.1 port 1022: Connection refused


      Update




      • I have changed the entry port for the forwarding from 1022 to 10001, because with port 1022 forwarding wasn't working with NAT either.

      • When I use port 10001 for forwarding, I can see the on the host VirtualBox is actually listening on that port:


      root@giacomo-ThinkPad:~# netstat -tulpn
      Active Internet connections (only servers)
      Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
      tcp 0 0 0.0.0.0:10001 0.0.0.0:* LISTEN 2482/VirtualBox
      tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1489/dnsmasq


      Instead when using the same forwarding rules with NAT Network, VirtualBox is not listening. So it looks like the problem might be in VirtualBox?







      networking ubuntu ssh virtualbox nat






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 17 at 18:13









      Ahmed Ashour

      1,3201715




      1,3201715










      asked Jan 17 at 16:43









      mangitsimangitsi

      15




      15






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The problem was solved by installing VirtualBox 6.0. With it everything port forwarding from localhost:10001 started working also with NAT Network.






          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',
            autoActivateHeartbeat: false,
            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%2f1395456%2fvirtualbox-nat-network-port-forwarding-refuses-connection%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









            0














            The problem was solved by installing VirtualBox 6.0. With it everything port forwarding from localhost:10001 started working also with NAT Network.






            share|improve this answer




























              0














              The problem was solved by installing VirtualBox 6.0. With it everything port forwarding from localhost:10001 started working also with NAT Network.






              share|improve this answer


























                0












                0








                0







                The problem was solved by installing VirtualBox 6.0. With it everything port forwarding from localhost:10001 started working also with NAT Network.






                share|improve this answer













                The problem was solved by installing VirtualBox 6.0. With it everything port forwarding from localhost:10001 started working also with NAT Network.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 17 at 19:10









                mangitsimangitsi

                15




                15






























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395456%2fvirtualbox-nat-network-port-forwarding-refuses-connection%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

                    Probability when a professor distributes a quiz and homework assignment to a class of n students.

                    Aardman Animations

                    Are they similar matrix