Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk11 min

How to Set Up iptables for FTP Passive Connections on Ubuntu

A successful FTP login does not prove passive data connections work. This guide shows how to set a bounded vsftpd passive range, create matching iptables rules, handle NAT and firewall ownership, inspect conntrack behavior, and troubleshoot stalled listings or transfers on Ubuntu.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If an FTP client can log in but hangs on directory listings or file transfers, opening TCP 21 alone is not enough. Passive FTP creates a second, server-side TCP connection. On Ubuntu, configure vsftpd with a fixed passive-port range, allow TCP 21 and that entire range through the host firewall and any NAT or cloud firewall, and allow established or related connections. The range in the firewall must exactly match the daemon configuration.

Why passive FTP needs more than port 21

FTP uses two connections. The control connection carries commands and normally reaches the server on TCP port 21. A passive-mode data connection is opened separately: the client asks the server for a passive endpoint, and then connects to the address and port returned in the server’s PASV response. Directory listings, uploads, and downloads use that data connection.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

That design explains the common symptom: authentication succeeds because TCP 21 is reachable, but LIST, uploads, or downloads time out because the negotiated data port is blocked, not forwarded, or advertised with an unreachable address. A passive range also matters operationally because each simultaneous transfer needs an available port.

Ubuntu’s documented defaults for vsftpd’s pasv_min_port and pasv_max_port are both 0. With those defaults, vsftpd can choose from any available port, which makes a tightly scoped firewall rule impossible. Set an explicit range before writing the iptables rule.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Check which firewall owns the host before changing rules

Ubuntu can expose iptables commands through the nftables API. Ubuntu states that this compatibility package has been available since Ubuntu 16.04, and that the nftables backend became the default in Ubuntu 20.10. The command syntax alone therefore does not tell you whether the host is using the legacy or nftables-backed implementation.

  1. Identify the iptables alternative: run sudo update-alternatives --display iptables and note the selected path.
  2. Inspect current IPv4 rules: run sudo iptables -L INPUT -n -v --line-numbers and, when needed, sudo iptables -S. Look for the default policy, existing TCP 21 rules, and an existing established/related rule.
  3. Check for UFW: run sudo ufw status verbose. If UFW is active, it should remain the system’s source of truth rather than being mixed casually with hand-written rules.
  4. Inspect native nftables when it is the selected manager: run sudo nft list ruleset to see the live tables, chains, and policies.

Do not let two independent managers continually rewrite the same Netfilter hooks. A UFW policy, direct iptables commands, and a native nftables ruleset can overwrite or obscure one another. Choose the manager already controlling the machine, add the equivalent policy there, and use that manager’s persistence mechanism so the rules survive a reboot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The commands below show a representative IPv4 iptables pattern. They are not a complete replacement for an existing firewall policy. Insert them in the chain and order appropriate to the server’s current default policy, and test from an allowed client before closing your session.

Choose and document a passive-port range

The range should be large enough for the number of simultaneous data connections you expect, but no broader than your security policy requires. A small range reduces exposed ports and simplifies auditing; a larger range reduces the chance that concurrent transfers run out of ports. There is no universal Ubuntu number. The following range is an illustrative example, not an Ubuntu default:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
30000-31000

Record the chosen range in your change notes. The same lower and upper values must appear in vsftpd, the host firewall, every perimeter or cloud firewall, and every NAT forwarding rule. If one layer allows only part of the range, some transfers will work while others fail unpredictably.

Configure vsftpd for passive mode

Edit the daemon configuration

Open the vsftpd configuration file, normally /etc/vsftpd.conf, with an editor that preserves the exact option names. Add or adjust:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=31000
# Set this only when NAT or another advertised address requires it:
# pasv_address=203.0.113.10

pasv_enable=YES enables passive mode. The two port settings bound the ports vsftpd may announce. The commented pasv_address line is intentional: on a directly addressed host, vsftpd can normally advertise its local address. When the server is behind NAT, or must advertise a different reachable address, set pasv_address to the public address clients can actually reach. The example address belongs to a documentation-only range; replace it with your real public address.

Do not set pasv_address to a private address when clients arrive over the internet. Conversely, do not force a public address for an internal-only deployment unless internal clients can route to it. A wrong address in the PASV reply can produce a successful login followed by a failed listing even when every firewall port is open.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Apply and verify the change

  1. Save the file and restart or reload vsftpd using the service method used by the host, for example sudo systemctl restart vsftpd.
  2. Check the service state with sudo systemctl status vsftpd. Correct configuration syntax or service-start errors before changing firewall rules.
  3. Confirm that the running configuration contains the intended minimum and maximum values. A stale process using the old range will not match the new iptables policy.

Add the IPv4 iptables rules

Once the daemon and range agree, a common inbound pattern is:

sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 21 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 30000:31000 -j ACCEPT

The first rule accepts packets belonging to connections the host already knows about, including traffic classified as related to an existing connection. The second admits the FTP control connection. The third admits every port in the example passive range. Replace 30000:31000 with the exact values configured in vsftpd.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Place the rules safely

If the INPUT chain has an early DROP or REJECT, appending an allow rule after it will not help. Review the numbered chain first and insert the rules before the terminating deny, or place them in the site’s designated service chain. If the host already has an established/related rule, do not create needless duplicates; verify its state match and position instead.

Opening the range to every source is the simplest pattern but is not always the best one. When clients come from known networks, apply the site’s source restriction to both TCP 21 and the passive range. Keep the range as narrow as practical, and do not remove unrelated protections merely to make FTP work.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

The commands above are for IPv4. If the service is reachable over IPv6, IPv6 firewall policy and routing must be reviewed separately; an IPv4 rule does not create IPv6 access.

Make the rules survive reboot without creating a second policy

Rules entered with the iptables command are live kernel state. Whether they survive a reboot depends on the firewall manager and persistence mechanism already used by the machine. Save the policy through that owner: use the existing UFW configuration if UFW owns the host, the site’s nftables configuration if native nftables owns it, or the approved iptables persistence method if direct iptables is the established approach.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After saving, reboot or reload in a maintenance window and inspect the live rules again. Confirm that the established/related rule, TCP 21 rule, and the complete passive range are present exactly once. A persistence tool that restores an older range can silently reintroduce the login-works-but-transfer-fails symptom.

Handle NAT, cloud firewalls, and perimeter devices

A server behind a router or load-balancing firewall needs the same ports opened at every layer. Forward TCP 21 to the FTP host and forward the entire passive range, not just one sample port. A cloud security group, data-center ACL, or perimeter firewall must also permit those destinations.

Set pasv_address to the public address that remote clients should use when the server’s local address is not that public address. Then verify that the NAT device forwards that address and each passive port to the same internal host. If the advertised address and the forwarding rule disagree, the control connection can still authenticate while the data connection goes to the wrong machine or an unroutable private address.

For a directly public host, no destination NAT is needed, but the host firewall and any upstream security policy still need TCP 21 and the selected passive range. For a private-only deployment, advertise an address reachable by the internal clients and avoid exposing the service externally unless that exposure is deliberate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand conntrack and FTP helpers

Linux connection tracking records the control flow and can classify a data flow as RELATED. That classification is what makes the first rule in the pattern useful. Ubuntu documents conntrack as the state-tracking layer, but helper assignment is not identical on every kernel, nftables configuration, or Ubuntu release.

Do not copy one FTP-helper command and assume it is universal. Inspect the active ruleset and connection-tracking behavior on the actual host. Encrypted FTPS adds another complication because the control channel is protected; a helper may not be able to read the negotiated details in the same way as plain FTP. Explicitly allowing the bounded passive range remains necessary even when a helper is present.

When diagnosing a failure, use packet capture or conntrack inspection to answer two concrete questions: does the client reach the advertised address and port, and does the kernel classify the resulting flow as expected? The answer is more reliable than assuming a helper is active merely because port 21 is open.

Test the complete path

  1. Test authentication first. Confirm that the client can establish the control connection and log in. If it cannot, troubleshoot TCP 21, credentials, and the daemon separately from passive mode.
  2. Trigger a data operation. Request a directory listing, download, and upload. A listing exercises the same passive data path as a transfer and often reveals the problem quickly.
  3. Read the PASV response. Record the address and port returned by the server. The address must be reachable from the client, and the port must fall inside the configured range.
  4. Check each firewall layer. Verify the host INPUT policy, cloud or perimeter rules, and NAT forwarding for TCP 21 and the full range. A single missing layer is enough to block the data connection.
  5. Watch live traffic. Use packet capture on the server or inspect conntrack entries while starting a listing. Determine whether the SYN reaches the host, whether a reply leaves, and whether the flow is marked related.
  6. Recheck after reloads. If you edited vsftpd or changed the firewall manager, restart or reload the relevant service and repeat the listing. Testing only an old established session can hide a configuration mismatch.

Troubleshoot by symptom

Login fails as well as transfers

  • Confirm that the daemon is listening on TCP 21 and that the INPUT chain allows it before a blanket DROP or REJECT.
  • Check upstream security groups and perimeter ACLs; a host rule cannot override a blocked network edge.
  • Verify that you are editing the configuration for the running vsftpd instance and that the service restarted successfully.

Login succeeds, but listings and transfers hang

  • Compare pasv_min_port and pasv_max_port with the iptables range. A one-port difference is enough to fail some or all transfers.
  • Inspect the PASV reply. If it advertises a private, stale, or otherwise unreachable address, correct pasv_address and the NAT design.
  • Check forwarding and security rules for every port in the range, not only TCP 21.
  • Use packet capture or conntrack inspection to see whether the data SYN reaches the server and whether the return path is permitted.

Only some transfers fail

  • An incomplete range at a firewall or NAT device can allow selected ports while blocking others.
  • A range that is too small for concurrent sessions can leave later transfers without a free passive port. Expand it deliberately and mirror the change at every layer.
  • Duplicate or conflicting rules may send different packets through different chains. Identify the owning manager and remove stale policy from competing managers.

Plain FTP works, but FTPS does not

  • Opening passive ports does not make FTP confidential. FTPS encrypts FTP with TLS and SFTP is a different protocol carried over SSH.
  • Because encrypted control traffic can limit helper inspection, rely on an explicit bounded range, correct NAT, and observed conntrack behavior rather than assuming a helper can infer every related flow.

Compare the main deployment choices

Choice Operational benefit Trade-off Required configuration
Narrow passive range Fewer exposed ports and simpler auditing Less capacity for simultaneous data connections Set matching minimum and maximum values in vsftpd, iptables, and every network firewall
Broad passive range More room for concurrent transfers More ports exposed and more rules to review Allow and forward the complete range consistently
Direct public hosting No destination NAT or translated PASV address The host itself is exposed to the internet Permit TCP 21 and the passive range at the host and upstream edge
Hosting behind NAT Private server address can remain off the public network Requires port forwarding and a correct advertised address Forward TCP 21 and the full range; set pasv_address when the local address is not reachable by clients
Plain FTP Legacy clients can connect without TLS negotiation Credentials and file data are sent in clear text Use only where that exposure is acceptable and controlled
FTPS FTP protocol with TLS protection Encrypted control traffic can complicate helper inspection Keep passive ports explicit and verify observed conntrack and NAT behavior
SFTP File transfer over SSH rather than FTP’s separate data channel Requires an SFTP-capable client and SSH service Use SSH policy instead of FTP passive-port rules
Direct iptables commands Immediate, precise rule changes Easy to lose at reboot or conflict with another manager Persist through the established owner and avoid parallel rule managers
UFW or native nftables ownership One consistent policy and persistence model Raw iptables commands may not represent the complete managed policy Add the equivalent service and range policy in the active manager

Security limits you should not overlook

Ubuntu’s FTP guidance describes FTP as a TCP protocol for downloading files and warns that FTP credentials and data are sent in clear text. Passive-port rules solve reachability; they do not provide confidentiality, integrity, or protection against credential interception. If the service crosses an untrusted network, evaluate FTPS or SFTP instead. FTPS remains FTP with TLS, while SFTP is a separate file-transfer protocol over SSH.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Even when plain FTP is required for compatibility, reduce exposure by restricting source networks where possible, choosing the smallest range that supports expected concurrency, limiting access at upstream firewalls, and reviewing the advertised address. Treat every opened passive port as part of the service’s attack surface.

Deployment checklist

  • vsftpd has passive mode enabled.
  • pasv_min_port and pasv_max_port define a deliberate, documented range.
  • pasv_address is set only when clients need an address different from the server’s local address, and that address is reachable.
  • vsftpd was restarted or reloaded after editing, and its service status is healthy.
  • The active firewall owner is known; UFW, direct iptables, and native nftables are not competing to manage the same policy.
  • The INPUT policy accepts established and related traffic, TCP 21, and the entire passive range in the correct chain order.
  • Cloud security groups, perimeter ACLs, and NAT forward the same ports.
  • A real client can log in, list a directory, download, and upload while packet or conntrack inspection confirms the data path.
  • The chosen policy is persisted through the owning firewall manager and survives a reboot test.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.