Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 为什么Capistrano在执行特定的iptables命令时会锁定?_Linux_Capistrano_Iptables - Fatal编程技术网

Linux 为什么Capistrano在执行特定的iptables命令时会锁定?

Linux 为什么Capistrano在执行特定的iptables命令时会锁定?,linux,capistrano,iptables,Linux,Capistrano,Iptables,我正在尝试使用Capistrano远程打开iptables防火墙中的端口。我的任务是: 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 "#{

我正在尝试使用Capistrano远程打开iptables防火墙中的端口。我的任务是:

  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
问题是任务中的第一个命令被锁定。我尝试使用各种端口号和目标机器运行此规则,结果总是一样的

我有很多其他的规则,看起来很像这个,但效果很好。事实上,我有一个类似的任务,其中第一个命令是调用iptables来创建端口映射,该任务工作正常

此外,我还可以在Capistrano主机上成功运行此命令:

  ssh -l deployer core sudo /sbin/iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 2424 -j ACCEPT
这个很好用。这正是卡皮斯特拉诺试图做的

为什么这个命令要锁定Capistrano

TIA寻求解决方案或任何线索


祝大家玩得开心

前几天我自己弄明白了。问题是我使用名称“port”作为任务的参数。“parameter”端口由“run”命令识别,并使系统尝试通过该端口而不是普通ssh端口连接到目标计算机。因此被拘留

我将参数名更改为“dport”,任务开始按预期工作