免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2366 | 回复: 4
打印 上一主题 下一主题

如何让非root用户启用小于1024号的端口? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-10-15 11:04 |只看该作者 |倒序浏览
如题,请高手指教,谢谢。

论坛徽章:
0
2 [报告]
发表于 2010-10-15 12:05 |只看该作者

论坛徽章:
0
3 [报告]
发表于 2010-10-15 12:59 |只看该作者
*

      Using SetUID

      Set user ID on execution bit for user application can make this application be able to run with root permission. this is dangerous for security especially when the application has any vulnerability.

      # chown root.root /path/to/program
      # chmod u+s /path/to/program

      
    *

      Using CAP_NET_BIND_SERVICE

      It is possible to bind low ports even though a service is running as a non-root user with CAP_NET_BIND_SERVICE capacity.

      # setcap cap_net_bind_service=+ep /path/to/program

      

      Note 1 : Red Hat Enterprise Linux 4, 5 do not provide this capacity. To use this, Fedora 11 or newer versions are required.

      Note 2 : This won't work if the progmam file is a script.

      
    *

      Using Port forwarding

      If the application has a capability to listen other ports, run the application on a high port and forward a low port to it. It can also be done using an iptables forwarding rule as shown below.

      

      Enable the IP forward kernel parameter:

      # sysctl -w net.ipv4.ip_forward=1

      

      Make iptable rules to redirect packets heading for 80 port to 8888 port which the program will listen.

      # iptables -F -t nat
      # iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to :8888

      

      Then, run the program with a normal user.

招聘 : 技术支持/维
论坛徽章:
0
4 [报告]
发表于 2010-10-15 13:02 |只看该作者
楼上正解

论坛徽章:
0
5 [报告]
发表于 2010-10-15 22:43 |只看该作者
deamon 的运行uid设定为非root用户,启动监听其端口。

3楼的意思没弄懂。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP