Clone a node programmatically I am modifying the node content on hook_form_alter() as follows.

  $node = \Drupal\node\Entity\Node::load($nid);
  if ($node) {
    $node-&gt;field_p_frontip = $availableip[0];
    $node-&gt;save();
  }


I need to clone the node and save it in the  hook_form_alter() submission. How could I do this?

UPDATE



In D6 the node was cloned using the function clone_node_save which uses the node id to clone as clone_node_save($nid,false);, what is the corresponding function in D8 ??
In Drupal 8, any entity can be cloned using EntityInterface::createDuplicate(). So in the case of your node object: $cloned_node = $node-&gt;createDuplicate(). Calling $cloned_node-&gt;save() will save a new node with a different ID.