Raw IP packets on Linux

M

Mike Ayers

I am trying to compose raw IP packets on Linux, then send them out a chosen
interface. So I do:

sock = socket.socket( socket.AF_PACKET, socket.SOCK_DGRAM )
sock.bind(( '192.168.1.3' ))

So far so good. I create a packet (pkt) which contains the complete IP
datagram. ID is set to 0 to tell the kernel to stamp it for me. However, I am
so far unable to send the packet (pretend ']' is '>'):

]]] sock.sendto( pkt, ('192.168.1.4', 0))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
socket.error: (19, 'No such device')


What am I getting wrong here? What address type does this socket expect?


Thanks,

/|/|ike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top