说明:在Ubuntu上非root用户只能使用1024端口以上端口,即0-1023对非root用户为禁用状态。需要使用iptables的转发功能,把80端口(外部访问端口)消息转发给8080端口(目标端口)。
本文所述操作预期达成效果:Web访问地址不需要加端口号即可正常访问相关应用程序。
1)查看系统是否安装iptables防火墙。
#whereis iptables
iptables:/sbin/iptables/etc/iptables.rules/usr/share/iptables/usr/share/man/man8/iptables.8.gz
上述返回结果为已安装状态,按3)进行后续操作,否则按2)所述进行安装。
2)安装iptables防火墙。
#apt-get install iptables
3) 查看防火墙配置信息。
#iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
4) 配置防火墙访问控制规则。
创建iptables.rules文件:
#vim /etc/iptables.rules
添加下列内容:
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:syn-flood - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT