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
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.
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.
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.
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.
Step 2 – Expand Advanced Options
Click the Advanced arrow to expand the advanced network options panel.
Step 3 – Open Port Forwarding
Click the Port Forwarding button.
Step 4 – Add a New Rule
Click the Add (+) icon in the top-right corner and create a new rule as shown below.
| Field | Value |
|---|---|
| Name | SSH (or any label you prefer) |
| Protocol | TCP |
| Host IP | 127.0.1.1 |
| Host Port | 22 |
| Guest IP | (leave blank) |
| Guest Port | 22 |
Step 5 – Configure FileZilla
Open FileZilla on Windows, go to File > Site Manager, and fill in the connection details as follows:
| Field | Value |
|---|---|
| Host | 127.0.1.1 |
| Port | 22 |
| Protocol | SFTP – SSH File Transfer Protocol |
| Logon Type | Normal |
| User | your VM username |
| Password | your VM password |
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.
Summary
| Situation | Result |
|---|---|
| Bridge mode, restrictive AP | VM gets no IP from router DHCP – unusable |
| NAT mode, no port forwarding | VM gets IP but host cannot initiate connections into VM |
| NAT mode + port forwarding rule | VM has IP and FileZilla SFTP works via loopback forwarding |
Tq for sharing, sir..
Exactly what I needed. Thanks for posting!
Thanks for sharing, this post is very helpful
Still helpful in 2021. Thanks!!