advantage : Support arbitrary permissions , Unlike ICMP Administrator permission is required
shortcoming : Slow speed , Scan one C It's about 10 About seconds
usage : Ladon 192.168.1.1/24 PingScan
Use LadonGo
go get github.com/k8gege/LadonGo
package main
import (
"fmt"
"flag"
"os"
"github.com/k8gege/LadonGo/ping"
)
//go run pingtest.go -host k8gege.org
var (
host string
)
func init() {
flag.StringVar(&host, "host", "", "IP/Host/Domain")
}
func main() {
flag.Parse()
if host == "" {
println("Please " + os.Args[0] + " -h")
os.Exit(0)
}
res,err := ping.CmdPing(host)
//res,err := CmdPing("k8gege.org")
if err==nil && res==true {
fmt.Println(host+" IsOnline")
}
}