python bind socket.error: [Errno 13] Permission denied

后端 未结 2 1043
故里飘歌
故里飘歌 2020-12-25 13:46

I have a python script which gets packets from a remote machine and writes them (os.write(self.tun_fd.fileno(), \'\'.join(packet))) to a tun interface gr3:

         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 14:23

    You can't bind to port numbers lower than 1024 as a unprivileged user.

    So you should either:

    • Use a port number larger than 1024 (recommended)
    • Or run the script as a privileged user

    Harder, but more secure solution if it's really necessary to accept from 111:

    • Run the as unprivileged on a higher port, and forward port 111 to it externally.

提交回复
热议问题