Custom ROMs are great as they provide you with many customization options and a better interface which the stock firmware does not provide. You can therefore not resist, but take up the risk to flash the ROMs. But did you notice that your IMEI gets changed when you flash the custom ROMs? This happens when the EFS folder in the root folder of your phone gets changed. The IMEI stored in the “.nv_data” file in ORIGINAL SHIPPED EFS folder.
The process of recovering your IMEI on Samsung Galaxy SII involves, backing up .nv_data file and restoring the one which comes with the stock firmware.You can do this manually using the method posted by vaskodogamagmail which can be found here.
If you do not wish to do it manually, you can use this simple application by Helroz.
GSII_repair is an app which lets you recover your IMEI on your Samsung Galaxy S2 easily.
You can install this application from Google Play from the link given at the end of the post. Open the app and select Save actual EFS folder. You can also backup your current EFS folder using this app.