ugly solve restore ip address

should be refactor with stack or queue, it will be more elegant