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