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 / gowri
set ip "10.10.10.1"
lappend result [ regexp (\[0-9]+\) (\[0-9]+\) (\[0-9]+\) (\[0-9]+\) $ip match val1 val2 val3 val4]
puts $val1
puts $val2
puts $val3
puts $val4
if {$val1 > 255} {
set val1 0
incr val2
if {$val2 > 255 } {
set val2 0
incr val3
if {$val3 >255} {
set val3 0
incr val4
if {$val4 > 255} {
set val4 0
}}} else {
incr val5
lappend result1 "$val1.$val2.$val3.$val4"
puts $result1
}
Is This Answer Correct ? | 3 Yes | 7 No |
Post New Answer View All Answers