{"record":{"id":"7e01300570fd5e4e","repo":"probelabs/goreplay","slug":"promiscuous-mode-error-q-interface-q","errorCode":null,"errorMessage":"promiscuous mode error: %q, interface: %q","messagePattern":"promiscuous mode error: %q, interface: %q","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/capture/capture.go","lineNumber":422,"sourceCode":"\tvar inactive *pcap.InactiveHandle\n\tinactive, err = pcap.NewInactiveHandle(ifi.Name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"inactive handle error: %q, interface: %q\", err, ifi.Name)\n\t}\n\tdefer inactive.CleanUp()\n\n\tif l.config.TimestampType != \"\" && l.config.TimestampType != \"go\" {\n\t\tvar ts pcap.TimestampSource\n\t\tts, err = pcap.TimestampSourceFromString(l.config.TimestampType)\n\t\tfmt.Println(\"Setting custom Timestamp Source. Supported values: `go`, \", inactive.SupportedTimestamps())\n\t\terr = inactive.SetTimestampSource(ts)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"%q: supported timestamps: %q, interface: %q\", err, inactive.SupportedTimestamps(), ifi.Name)\n\t\t}\n\t}\n\tif l.config.Promiscuous {\n\t\tif err = inactive.SetPromisc(l.config.Promiscuous); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"promiscuous mode error: %q, interface: %q\", err, ifi.Name)\n\t\t}\n\t}\n\tif l.config.Monitor {\n\t\tif err = inactive.SetRFMon(l.config.Monitor); err != nil && !errors.Is(err, pcap.CannotSetRFMon) {\n\t\t\treturn nil, fmt.Errorf(\"monitor mode error: %q, interface: %q\", err, ifi.Name)\n\t\t}\n\t}\n\n\tvar snap int\n\n\tif !l.config.Snaplen {\n\t\tinfs, _ := net.Interfaces()\n\t\tfor _, i := range infs {\n\t\t\tif i.Name == ifi.Name {\n\t\t\t\tsnap = i.MTU + 200\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/probelabs/goreplay/blob/251e45abd242886bb64ff2b2dc98789556b56330/internal/capture/capture.go#L404-L440","documentation":"If config.Promiscuous is true, PcapHandle calls inactive.SetPromisc; failure is wrapped as \"promiscuous mode error: <err>, interface: <name>\". Enabling promiscuous mode makes the interface pass all frames to the socket; the error means libpcap could not set that option on the inactive handle before activation.","triggerScenarios":"Configuring l.config.Promiscuous = true and SetPromisc returning an error, typically when the handle/interface is in a state that cannot accept the option or on platforms where the ioctl fails.","commonSituations":"Capturing on a device that does not support promiscuous mode (e.g. some tunnels/loopback); running without sufficient privileges in restricted environments; wrappers where SetPromisc is unimplemented.","solutions":["Run the capture process with CAP_NET_RAW/root so libpcap can apply socket options","Set config.Promiscuous = false if the capture does not strictly need all traffic","Test the interface type; skip promiscuous for loopback/tunnel devices","Capture the underlying wrapped error (%q) to see the libpcap cause"],"exampleFix":"// before\ncfg.Promiscuous = true // fails on unsupported iface\n// after\nif isLoopbackOrTunnel(iface) {\n    cfg.Promiscuous = false\n}","handlingStrategy":"validation","validationCode":"if cfg.Promiscuous {\n    if i, err := net.InterfaceByName(cfg.Iface); err != nil || i.Flags&net.FlagLoopback != 0 {\n        cfg.Promiscuous = false\n    }\n}","typeGuard":null,"tryCatchPattern":"handle, err := l.PcapHandle(ifi)\nif err != nil && strings.Contains(err.Error(), \"promiscuous mode error\") {\n    log.Warnf(\"promiscuous unavailable on %s, retrying without: %v\", ifi.Name, err)\n    cfg.Promiscuous = false\n    handle, err = l.PcapHandle(ifi)\n}","preventionTips":["Run with CAP_NET_RAW/root privileges","Disable promiscuous on loopback/tunnel devices where it is meaningless","Check the wrapped error for the libpcap cause before retrying"],"tags":["go","pcap","promiscuous","libpcap"],"backgroundTag":"promiscuous-mode-set-failed","analyzedSha":"251e45abd242886bb64ff2b2dc98789556b56330","analyzedAt":"2026-09-02T16:44:11.369Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}