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


i have python script gets packets remote machine , writes them (os.write(self.tun_fd.fileno(), ''.join(packet))) tun interface gr3:

link encap:unspec  hwaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00   inet addr:10.0.0.6  p-t-p:10.0.0.8  mask:255.255.255.255 pointopoint running noarp multicast  mtu:1500  metric:1 rx packets:61 errors:0 dropped:0 overruns:0 frame:0 tx packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:500  rx bytes:5124 (5.0 kib)  tx bytes:0 (0.0 b) 

i receive packets via separate pong script follows:

import threading, os, sys, fcntl, struct, socket fcntl import ioctl packet import packet  host = '10.0.0.6' port = 111 s = socket.socket(socket.af_inet, socket.sock_stream) s.bind((host, port)) s.listen(1) conn, addr = s.accept() print 'connected by', addr while 1:     data = conn.recv(1024)     if not data: break     else: print data         conn.sendall(data) conn.close() 

i got error :

s.bind((host, port)) file "<string>", line 1, in bind socket.error: [errno 13] permission denied 

you can't bind port numbers lower 1024 unprivileged user.

so should either:

  • use port number larger 1024 (recommended)
  • or run script privileged user

harder, more secure solution if it's necessary accept 111:

  • run unprivileged on higher port, , forward port 111 externally.

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -