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 / pranav damele

set ip "10.10.10.255"
set list [split $ip "."]
set ww [lindex $list 0]
set xx [lindex $list 1]
set yy [lindex $list 2]
set zz [lindex $list 3]

if {$zz>254} {
set zz 0
incr yy
if {$yy>255} {
set yy 0
incr xx
if {$xx>255} {
set xx 0
incr ww }
if {$ww>255} {
set ww 0
}}} else {
incr zz
}
puts "$ww.$xx.$yy.$zz"

Is This Answer Correct ?    28 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Hi all, Is there any certification exams available for TCL and Perl. If so please let me know, my mailid is vpbharathi@gmail.com. Thanks in advance, Bharathi.P

2612