You need your d number to open a bank account, to rent a place to live and to pay your taxes.
When you get a d number depends on your situation. You can read more about d numbers on the Tax Administration's website (external website).
Then you may be entitled to a national identity number.
It is the Tax Administration that gives national identity numbers and decides whether you meet the conditions for being registered as a resident in Norway. If you receive a national identity number, use this instead of your d number.
If you have been granted a residence permit for six months or more, and you believe that you should have been registered as a resident in Norway and received a birth number instead of a d number, you can report a move to Norway. (external website)
A DUF number is not the same as a d number. The DUF number is your registration number in the computer system of the Norwegian Directorate of Immigration.