如何使用iptables为应用程序打开8080端口


17

我是一个关于服务器的新手,请原谅我谦虚的问题:-)

有人为我开发了一个充当Web服务的python应用程序。此TCP应用程序需要侦听端口8080。

[root@blabla jll]# netstat -tanpu | grep ":8080"
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      18209/python

看来我的服务器防火墙上没有打开8080。要打开它,我试图像这样修改iptables规则:

/sbin/iptables -A RH-Firewall-1-INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT

但是,我仍然没有http://my.server.name:8080的信息

(我什至不确定“ RH-Firewall-1-INPUT”或“ INPUT”)

我现在能做什么 ?这些事情有某种通用的程序吗?

我给您以下有用的信息:

/sbin/iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   49  3388 ACCEPT     tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:8080 
  25M 3736M RH-Firewall-1-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 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT 43M packets, 41G bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain RH-Firewall-1-INPUT (1 references)
 pkts bytes target     prot opt in     out     source               destination         
 121K   15M ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
97773 8078K ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 255 
    0     0 ACCEPT     esp  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     ah   --  *      *       0.0.0.0/0            0.0.0.0/0           
   17  2509 ACCEPT     udp  --  *      *       0.0.0.0/0            224.0.0.251         udp dpt:5353 
    0     0 ACCEPT     udp  --  *      *       0.0.0.0/0            0.0.0.0/0           udp dpt:631 
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:631 
  24M 3682M ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
26069 1319K ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
 3806  204K ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:443 
 563K   30M REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

和:

    /sbin/iptables -nvL -t nat
Chain PREROUTING (policy ACCEPT 168K packets, 15M bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 4200K packets, 252M bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 4200K packets, 252M bytes)
 pkts bytes target     prot opt in     out     source               destination

您的服务器上正在运行哪个操作系统?

我正在运行Fedora 8 Linux

@JCLL请发布的输出iptables-save,并且您的Web服务器与防火墙相同吗?
pepoluan 2011年

Answers:


32

除非输出iptables -nvLiptables -nvL -t nat并且iptables -nVL -t mangle,这将是在这种情况下非常有用,这里是一个匆匆可能的工作:

iptables -I INPUT 1 -i eth0 -p tcp --dport 8080 -j ACCEPT
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.