How do I give access permission for specific node to anonymous User
Give back the "Node access" permission (View published content) to Anonymous user and control the accesss with your custom module

use Drupal\Core\Access\AccessResult;
use Drupal\node\NodeInterface;

function MODULENAME_node_access(NodeInterface $node, $op, $account) {
  $allowed = [1,2];
  if ($op == "view" &amp;&amp; in_array($node-&gt;id(),$allowed)) {
    return AccessResult::allowed();
  }
  return AccessResult::forbidden();
}