How to ignore collision of the bullet with the player

When I shoot, the bullets are collides with my player.
How to fix that? I’ve tried this, but it doesn’t works:

void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.name != "Player")
        // ...
}

You can use tags (check here and here). Or use the layer system and the collision matrix.