Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1047713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:20:40+00:00 2026-05-16T16:20:40+00:00

I’m trying to remotely open a port in a iptables firewall using Capistrano. Here’s

  • 0

I’m trying to remotely open a port in a iptables firewall using Capistrano. Here’s my task:

  desc "Open up a port in the firewall"
  task :open_port, :roles => :all do
    port = variables[:port] || nil
    if (!port)
      puts "You must specify the port number"
      next
    end
    run "#{sudo} /sbin/iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport #{port.to_s} -j ACCEPT"
    run "#{sudo} /sbin/service iptables save"
    run "#{sudo} /etc/init.d/iptables restart"
  end

The problem is that the first command in the task locks up. I’ve tried running this rule using a variety of port numbers and target machines, always with the same result.

I’ve got literally many dozens of other rules that look much like this but that work fine. In fact, I’ve got a similar task where the first command is a call to iptables to create a port mapping and that task works just fine.

What’s more, I can successfully run this command on the Capistrano host:

  ssh -l deployer core sudo /sbin/iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 2424 -j ACCEPT

This works fine. This should be exactly what Capistrano is attempting to do.

Why is this command locking up Capistrano?

TIA for a solution or any clue whatsoever.

Have Fun All!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:20:41+00:00Added an answer on May 16, 2026 at 4:20 pm

    Figured this one out myself the other day. The problem was that I was using the name ‘port’ as the parameter to my task. The ‘parameter’ port is recognized by the ‘run’ command, and causes the system to try to connect to the target machine via that port rather than the normal ssh port. Hence the lockup.

    I changed my parameter name to ‘dport’, and the task started working as I expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.