PDA

View Full Version : Raw socket programming on Ubuntu



atkt_forever
April 29th, 2007, 11:16 PM
Hi

I have installed Ubuntu Drake 6.0 under Vmware (VMware is a virtual machine installed on windows XP). I need to write a C program using raw sockets

when i execute the code:

sockd = socket(AF_INET,SOCK_RAW,IPPROTO_RAW)

i get the result: operation not supported. is it that raw sockets are not supported on Ubuntu or I need to change some parameters.

thanx atkt

atkt_forever
April 30th, 2007, 02:24 AM
Hi I decided to post the answer to my own question to ppl. maybe it is obvious for ppl familiar wid Linux but not for me since i m using it for the first time. login as root first and then run the program that uses raw sockets. and then ur prog shud run. thanx

kano
April 30th, 2007, 04:37 AM
Or you could use a port that's >1024.

amo-ej1
April 30th, 2007, 06:49 AM
@kano no that's not true, raw sockets have nothing to do with portnumbers. You'll typically use a raw socket when you're building your own IP or ethernet packets.

When you read <i>man 7 raw</i>




Only processes with an effective user ID of 0 or the CAP_NET_RAW capa‐
bility are allowed to open raw sockets.

kano
May 1st, 2007, 07:23 AM
My bad, I read that too hastily :)