Raw IP packets on Linux

Discussion in 'Python' started by Mike Ayers, Aug 15, 2004.

  1. Mike Ayers

    Mike Ayers Guest

    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
    Mike Ayers, Aug 15, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. christos panagiotou

    reading .raw files (windows-linux)

    christos panagiotou, Jul 16, 2003, in forum: C++
    Replies:
    2
    Views:
    975
    Vasileios Zografos
    Jul 16, 2003
  2. galapogos

    Binding raw devices in Linux kernel 2.6

    galapogos, Jul 3, 2009, in forum: C Programming
    Replies:
    5
    Views:
    1,012
    galapogos
    Jul 8, 2009
  3. Giampaolo Rodolà

    Re: Sniffer Linux with Raw Socket

    Giampaolo Rodolà, Jun 6, 2010, in forum: Python
    Replies:
    0
    Views:
    760
    Giampaolo Rodolà
    Jun 6, 2010
  4. Andreas Leitgeb
    Replies:
    2
    Views:
    772
    Arne Vajhøj
    Aug 10, 2010
  5. lucas

    sending icmp packets with raw::ip

    lucas, Apr 27, 2005, in forum: Perl Misc
    Replies:
    0
    Views:
    581
    lucas
    Apr 27, 2005
Loading...

Share This Page