First of all, instead of playing with the code, read the docs.
You need to add the domain from server 1 as a 'shared domain' in server 2. Then you can add sub.shared-domain.com in the domain module on server 2.
You need to add the domain from server 1 as a 'shared domain' in server 2. Then you can add sub.shared-domain.com in the domain module on server 2.