为开发目的开放端口

为开发目的开放端口

我正在我的全新 Ubuntu 笔记本电脑上进行一些 Java ME 开发,之前使用的笔记本电脑已经被 Windows Vista 取代。

我想要做的是运行一个充当 HTTP 服务器的移动模拟器 - 接收到端口 80 的连接 - 并运行另一个充当客户端的模拟器,同时执行这两个任务。在 Windows Vista 中,这可以毫无问题地运行,当我将代码移植到 Windows 7 时,我需要关闭防火墙才能实现这一点。

但是,现在在我的 Ubuntu 笔记本电脑上我无法实现这一点。我读到一些帖子说 Unix 系统不需要防火墙,因为默认情况下会阻止几个端口,所以我的问题是如何打开这些端口以继续开发。我还会发出短信请求和蓝牙请求,所以我希望从本地主机到本地主机的任何请求都不会被阻止。

系統:运行 Ubuntu 11.1 64 位的 Dell Inspiron。使用 JDK 1.7 32 位在 Netbeans 中进行开发

更新:

根据要求,这里是堆栈跟踪:

java.io.IOException: ServerSocket Open
    at com.sun.midp.io.j2me.serversocket.Socket.open(Socket.java:69)
    at com.sun.midp.io.j2me.socket.Protocol.openPrim(Protocol.java:128)
    at javax.microedition.io.Connector.openPrim(Connector.java:329)
    at javax.microedition.io.Connector.open(Connector.java:222)
    at javax.microedition.io.Connector.open(Connector.java:198)
    at javax.microedition.io.Connector.open(Connector.java:180)
    at pe.edu.pucp.teleprocesamiento.server.http.HttpConnectionProcessor.run(HttpConnectionProcessor.java:43)

并且iptables -L -nv输出:

Chain INPUT (policy ACCEPT 35777 packets, 34M bytes)
 pkts bytes target     prot opt in     out     source               destination         
35779   34M ufw-before-logging-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
35779   34M ufw-before-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
35777   34M ufw-after-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
35777   34M ufw-after-logging-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
35777   34M ufw-reject-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
35777   34M ufw-track-input  all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ufw-before-logging-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 ufw-before-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 ufw-after-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 ufw-after-logging-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 ufw-reject-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain OUTPUT (policy ACCEPT 31810 packets, 3935K bytes)
 pkts bytes target     prot opt in     out     source               destination         
31812 3935K ufw-before-logging-output  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
31812 3935K ufw-before-output  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
31812 3935K ufw-after-output  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
31812 3935K ufw-after-logging-output  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
31812 3935K ufw-reject-output  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
31812 3935K ufw-track-output  all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain ufw-after-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-after-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-after-logging-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-after-logging-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-after-logging-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-after-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-logging-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-logging-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-logging-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-reject-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-reject-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-reject-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-track-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-track-output (1 references)
 pkts bytes target     prot opt in     out     source               destination  

答案1

将端口更改为高于 1024 的端口。只有 root 可以打开 <= 1024 的端口。

相关内容