How do i limit the range of a bullet

public GameObject bullet;

public Transform bulletSpawn;
public float fireRate;
private float nextFire;
public Rigidbody Bullet;
public float speed;   

void Update()
{
    if (Input.GetButton("Fire1") && Time.time > nextFire) //Fire1 = w
    {
        nextFire = Time.time + fireRate;
        Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation);
    }
}

void Start()
{
    Bullet.velocity = transform.forward * speed;  
}

a few different ways…
if you know the speed of a bullet, you can pre calculate how long it should be alive s=d/t
then after that time has past since firing… kill the object.
each Update just accumulate time its been alive. aliveTime += Time.deltatime
This would be the fastest, most performant way.
or…
in each Update… accumulate the distance moved with an a vector add. totalMoved += movedVector,
then check the squareMagnitude, to see if it passed max distance.
if(totalMoved.SqrMagnitude > maxSquared). then kill object.

or subtract bullets starting position from current position… to get a totalMoved. vector, and again check square magnitude.
Note:- squareMagnitude is much cheaper than checking magnitude (length) of a vector. So you should calculate maxSquared in Start(). and use that, to keep things performant.