To get the result you want, I would do this:
Do a global substitute on the ip addresses:
:%s/0/1/g
Do some macro-like action on the lines in question with the "global" command:
:g/\v(mail|ftp)/normal yypviwr $r2
This duplicates every line containing "mail" or "ftp", replaces the first word of the new line with spaces and finally, replaces its last char with "2".
See :h :g
for more help on the "global" command.