大家都知道低于 1024 的端口只能让高权限用户使用,但是一些时候呢,一些程序就需要开个低端口但是我不想提权.

很好,Linux 内核解决了这个问题.

setcap 'cap_net_bind_service=+ep' /path/to/program
#path to program 替换为程序绝对路径

这样这个程序就可以绑定到 1024 以内的端口了,Hooray!


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.