title: Why I cant create raw socket in Ubuntu?
body: <p>I'm learning how to work with raw sockets in Linux. I'm trying to create a socket like that:</p>
  
  <pre><code>if ((sd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) &lt; 0) {
      perror("socket() failed");
      exit(-1);
  }
  </code></pre>
  
  <p>But all I got after launch is:</p>
  
  <blockquote>
    <p>socket() failed: Operation not permitted</p>
  </blockquote>
  
  <p>I know that only root can create raw sockets, but if I run it with SUID bit or sudo - the 
  problem is the same. What's wrong? The system is Ubuntu 11.04.</p>
  
  <p>Maybe I'm including needless headers?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;netinet/ip.h&gt;
  #include &lt;netinet/ip_icmp.h&gt;
  #include &lt;netdb.h&gt;
  #include &lt;sys/time.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;unistd.h&gt;
  </code></pre>
  
  <p>And I'm wondering - why SUID is useless?</p>