我正在尝试创建一个Java程序,它是iptables的前端。为了达到这个目的,我使用了Java的Process类和pass命令。通过命令行与iptables进行交互
我想知道如果我一般正确地去做。例如,以下是一些将iptables重置为其默认设置的命令选项,这些命令旨在按顺序在终端中执行。我在这里正确使用Process类吗?
Process proc1 = Runtime.getRuntime().exec("iptables -P INPUT ACCEPT");
proc1.waitFor();
Process proc2 = Runtime.getRuntime().exec("iptables -P FORWARD ACCEPT");
proc2.waitFor();
Process proc3 = Runtime.getRuntime().exec("iptables -P OUTPUT ACCEPT");
proc3.waitFor();
Process proc4 = Runtime.getRuntime().exec("iptables -t nat -P PREROUTING ACCEPT");
proc4.waitFor();
感谢您的任何方向!
几乎没有任何关于使用多个命令的文档。 – 2010-11-07 02:08:19