Skip to contentSkip to conversation

Impossible to turn BROADCAST mode off on ethernet device?

DISCUSSION Denis Zaitsev 2 participants 2 messages May 19, 2003

lore
Share & tools
lore
#0 lore raw

Kernel 2.4.20. I do:

ifconfig eth0 -broadcast

And BROADCAST isn't turned off... The ethernet modules are: eepro100, tulip, 3c59x. So, what does it mean?

Thanks in advance.

#1 lore raw
Quoted 8 lines · Denis Zaitsev

Kernel 2.4.20. I do:

ifconfig eth0 -broadcast

And BROADCAST isn't turned off... The ethernet modules are: eepro100, tulip, 3c59x. So, what does it mean?

Thanks in advance.

Your ifconfig might not allow broadcast to be turned off as long a eth0 is up. So I just made a little program to get the flags, and reset the flags. This shows that your observation is, indeed, correct.

If you mess around with this, I think you will find that you can't set broadcast OFF as long at the IFF_UP flag is set. This may be the required behavior because an interface without broadcast capability will not work on ethernet because ARP requires it.

#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <string.h>
#include <net/if.h>

int main()

{
    struct ifreq ifr;
    int s, status;
    if((s = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)) == -1)
    {
        fprintf(stderr, "socket() failed (%s)\n", strerror(errno));
        return s;
    }
    memset(&ifr,  0x00, sizeof(ifr));
    ifr.ifr_netmask.sa_family = AF_INET;
    strcpy(ifr.ifr_name, "eth0");
    status = ioctl(s, SIOCGIFFLAGS, &ifr);
    ifr.ifr_flags &= ~IFF_BROADCAST;
    status = ioctl(s, SIOCGIFFLAGS, &ifr);

    (void)close(s);
    return status;
}

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips). Why is the government concerned about the lunatic fringe? Think about it.