Welcome to the Linux Foundation Forum!

Turn off promiscuous mode console messages

I created a thread to continually sniff certain network packets at the datalink layer every few seconds using libpcap. eth0 is being opened in promiscuous mode. I do not want to leave the pcap object open, so I am calling pcap_open_live() and pcap_close() each time in the loop. This results in

entered promiscuous mode

and

left promiscuous mode

messages continually printed to the console.

How do I turn off or delete these messages? I looked in the libpcap source code, but could not find these messages.

Comments

  • mfillpot
    mfillpot Posts: 2,177
    You can append "> /dev/null" at the end of each command to send the output to null so it will not be displayed.
  • jabirali
    jabirali Posts: 157
    Like mfillpot said, appending > /dev/null to your command will dispose of all output (stdout) of that command. If you also want to dispose of generated error messages (stderr), you can instead append &> /dev/null to completely silence your command.

    If you're actually interested in the output your command produces, except all the messages regarding promiscuous mode, you can also just filter the command output by appending | grep -v 'promiscuous mode' to the end of your command.
  • VFaul
    VFaul Posts: 4
    I understand I can redirect to null in comand line or script. However, the message is being displayed during library call to pcap_open_live() in the libpcap library.
    Anyways, I have found the printk statement in the kernel file /net/core/dev.c., function dev_set_promiscuity(). So, I just commented it out and rebuilt the kernel for my embedded system.

Categories

Upcoming Training