Hi, All, I used the following code snippet on a virtual box ubtunu vm trying to capture the packet. However, even though "enp3s0" is listed in the device list, opening it causes an error as follows. The same code runs on a physical box has no problem opening the NIC.
Any suggestions? TIA Devices found: Name: enp0s3 - IP address: 10.6.105.56 - Subnet mask: ffffff00 - IP address: fe80::d9a:740b:eb92:e270 - Subnet mask: ffffffffffffffff0000000000000000 <snip> open interface failed panic: runtime error: invalid memory address or nil pointer dereference panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4c4606] goroutine 1 [running]: panic(0x5313a0, 0xc42000c0a0) /usr/local/go/src/runtime/panic.go:500 +0x1a1 fmt.Println("Devices found:") for _, device := range devices { fmt.Println("\nName: ", device.Name) //fmt.Println("Description: ", device.Description) //fmt.Println("Devices addresses: ", device.Description) for _, address := range device.Addresses { fmt.Println("- IP address: ", address.IP) fmt.Println("- Subnet mask: ", address.Netmask) } } // Open device // handle, err = pcap.OpenLive(device, snapshot_len, promiscuous, timeout) handle, err = pcap.OpenLive("enp3s0", 1600, true, 100) //pcap.OpenLive("enp0s8", snapshot_len, promiscuous, timeout) if err == nil { fmt.Println("open interface ", device, "successfully") defer handle.Close() } else { fmt.Println("open interface failed") } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.