Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to get the next ip for given ip
ex: 10.10.10.1 -> 10.10.10.2
ex: 10.10.10.255 -> 10.10.11.0

Answer Posted / karthik

proc next_ipv4 {a} {
regexp {([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)} $a b
set b [split $b .]
if {[lindex $b 3] < 255} {
set c [lindex $b 3]
set c [expr $c +1]
set b [lreplace $b 3 3 $c]
set b [join $b .]
puts "next IP is $b"
} elseif {[lindex $b 2] < 255} {
set c [lindex $b 2]
set c [expr $c +1]
set b [lreplace $b 2 3 $c 1]
set b [join $b .]
puts "Next IP is $b"
} elseif {[lindex $b 1] < 255} {
set c [lindex $b 1]
set c [expr $c +1]
set b [lreplace $b 1 3 $c 0 1]
set b [join $b .]
puts "next IP is $b"
} elseif {[lindex $b 0] < 255} {
set c [lindex $b 0]
set c [expr $c +1]

set b [lreplace $b 0 3 $c 0 0 1]
set b [join $b .]
puts "next IP is $b"
} else {
puts "Last IPv4 address is 255.255.255.255"
}
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category