Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "log"
- "net"
- )
- func main() {
- ip, ipnet, err := net.ParseCIDR("62.76.47.12/28")
- if err != nil {
- log.Fatal(err)
- }
- for ip := ip.Mask(ipnet.Mask); ipnet.Contains(ip); inc(ip) {
- fmt.Println(ip)
- }
- }
- func inc(ip net.IP) {
- for j := len(ip)-1; j>=0; j-- {
- ip[j]++
- if ip[j] > 0 {
- break
- }
- }
- }
Add Comment
Please, Sign In to add comment