VirtualBox NAT and FileZilla: Fixing File Transfer When Bridge Mode Has No IP

How to set up port forwarding in VirtualBox so FileZilla can reach your Linux VM over NAT

Vivek Bhadra  |  VirtualBox Ubuntu Networking FileZilla SFTP

The Problem

I run an Ubuntu Linux Virtual Machine on a Windows host. Because of specific requirements I need to connect to a particular AP (Wi-Fi router) from the Windows machine. When I run my VM in Bridge mode, the VM gets no IP address at all.

VirtualBox Bridge mode network settings
VirtualBox network adapter set to Bridged – no IP assigned to the VM
vbhadra@vbhadra-VirtualBox:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:1a:13:10
          inet6 addr: fe80::a00:27ff:fe1a:1310/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8819 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7621 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4477485 (4.4 MB)  TX bytes:3415333 (3.4 MB)

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:65536  Metric:1
          RX packets:1671 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1671 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:157039 (157.0 KB)  TX bytes:157039 (157.0 KB)

As shown above, eth0 has no inet addr line – the VM has received no IPv4 address.

Why does this happen? This is not a VirtualBox bug. In Bridge mode the VM appears as a distinct device on the physical network and must receive an IP from the router’s DHCP server directly. Some routers or access points have firewall rules that block DHCP responses to unknown MAC addresses, which prevents the VM from getting a lease. Switching to a different AP typically resolves the problem, which confirms it is a router-side policy, not a VirtualBox issue.

NAT Mode Gives an IP – But Breaks FileZilla

Switching the VM network adapter to NAT mode solves the no-IP problem. VirtualBox creates a private internal network and the VM receives an address via its built-in DHCP server.

VirtualBox NAT mode network settings
VirtualBox network adapter set to NAT – the VM now receives an IP
vbhadra@vbhadra-VirtualBox:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:1a:13:10
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe1a:1310/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8821 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7657 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4478330 (4.4 MB)  TX bytes:3422460 (3.4 MB)

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:65536  Metric:1
          RX packets:1703 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1703 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:159423 (159.4 KB)  TX bytes:159423 (159.4 KB)

The VM now has IP 10.0.2.15. NAT mode creates a private network for the VM to reach the host network through address translation. However, the trade-off is that the Windows host cannot initiate connections into the VM – which means FileZilla’s SFTP connection from Windows to the VM no longer works.

The Fix: Port Forwarding in VirtualBox

The solution is to add a port forwarding rule in VirtualBox. This tells VirtualBox to forward any connection arriving on a specific port on the Windows host through to the VM, effectively punching a hole through NAT. Follow these steps.

Step 1 – Open VirtualBox Network Settings

Open the VirtualBox Manager (version 5.1.30), select your VM, and click Settings > Network.

VirtualBox Manager - Network settings
VirtualBox Manager: navigate to Settings then Network

Step 2 – Expand Advanced Options

Click the Advanced arrow to expand the advanced network options panel.

VirtualBox Network Advanced settings
Click Advanced to reveal the Port Forwarding button

Step 3 – Open Port Forwarding

Click the Port Forwarding button.

VirtualBox Port Forwarding dialog
The Port Forwarding rules dialog

Step 4 – Add a New Rule

Click the Add (+) icon in the top-right corner and create a new rule as shown below.

VirtualBox port forwarding rule for SSH
Port forwarding rule: host port 22 forwarded to guest port 22 over TCP
FieldValue
NameSSH (or any label you prefer)
ProtocolTCP
Host IP127.0.1.1
Host Port22
Guest IP(leave blank)
Guest Port22

Step 5 – Configure FileZilla

Open FileZilla on Windows, go to File > Site Manager, and fill in the connection details as follows:

FileZilla Site Manager settings
FileZilla Site Manager: connect via SFTP to the host loopback address on port 22
FieldValue
Host127.0.1.1
Port22
ProtocolSFTP – SSH File Transfer Protocol
Logon TypeNormal
Useryour VM username
Passwordyour VM password
Why 127.0.1.1? From FileZilla’s perspective you are connecting to the Windows host’s loopback address. VirtualBox intercepts the connection on port 22 and forwards it through NAT into the VM’s SSH daemon. The VM never needs a routable IP – the forwarding rule handles the translation transparently.

Step 6 – Connect and Transfer

Click Connect. FileZilla will establish an SFTP session with the VM and you can transfer files freely between Windows and the Linux guest.

FileZilla connected to the Ubuntu VM
FileZilla successfully connected to the Ubuntu VM via the VirtualBox port forwarding rule

Summary

SituationResult
Bridge mode, restrictive APVM gets no IP from router DHCP – unusable
NAT mode, no port forwardingVM gets IP but host cannot initiate connections into VM
NAT mode + port forwarding ruleVM has IP and FileZilla SFTP works via loopback forwarding

4 Comments

Leave a Reply to Trent WeaverCancel reply