diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php
index 83dffaa..a5f1966 100644
--- a/core/modules/comment/src/Entity/Comment.php
+++ b/core/modules/comment/src/Entity/Comment.php
@@ -151,9 +151,11 @@ public function preSave(EntityStorageInterface $storage) {
       if ($this->getOwnerId() === \Drupal::currentUser()->id() && \Drupal::currentUser()->isAuthenticated()) {
         $this->setAuthorName(\Drupal::currentUser()->getUsername());
       }
-      // Add the values which aren't passed into the function.
       $this->setThread($thread);
-      $this->setHostname(\Drupal::request()->getClientIP());
+      if (!$this->getHostname()) {
+        // Ensure a client host from the current request.
+        $this->setHostname(\Drupal::request()->getClientIP());
+      }
     }
   }
 
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTest.php
index 5330e94..c417c75 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d6/MigrateCommentTest.php
@@ -61,14 +61,17 @@ public function testComments() {
     $this->assertIdentical('node', $comment->getCommentedEntityTypeId());
     $this->assertIdentical('en', $comment->language()->getId());
     $this->assertIdentical('comment_no_subject', $comment->getTypeId());
+    $this->assertEquals('203.0.113.1', $comment->getHostname());
 
     $comment = $comment_storage->load(2);
     $this->assertIdentical('The response to the second comment.', $comment->subject->value);
     $this->assertIdentical('3', $comment->pid->target_id);
+    $this->assertEquals('203.0.113.2', $comment->getHostname());
 
     $comment = $comment_storage->load(3);
     $this->assertIdentical('The second comment.', $comment->subject->value);
     $this->assertIdentical(NULL, $comment->pid->target_id);
+    $this->assertEquals('203.0.113.3', $comment->getHostname());
   }
 
 }
diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
index f1e094f..a22bbe6 100644
--- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
+++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php
@@ -61,6 +61,7 @@ public function testCommentMigration() {
     $this->assertIdentical('admin@local.host', $comment->getAuthorEmail());
     $this->assertIdentical('This is a comment', $comment->comment_body->value);
     $this->assertIdentical('filtered_html', $comment->comment_body->format);
+    $this->assertEquals('2001:db8:ffff:ffff:ffff:ffff:ffff:ffff', $comment->getHostname());
 
     $node = $comment->getCommentedEntity();
     $this->assertTrue($node instanceof NodeInterface);
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
index 4dd1418..1092c11 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
@@ -1772,7 +1772,7 @@
   'uid' => '0',
   'subject' => 'The first comment.',
   'comment' => 'The first comment body.',
-  'hostname' => '127.0.0.1',
+  'hostname' => '203.0.113.1',
   'timestamp' => '1390264918',
   'status' => '0',
   'format' => '1',
@@ -1788,7 +1788,7 @@
   'uid' => '0',
   'subject' => 'The response to the second comment.',
   'comment' => 'The second comment response body.',
-  'hostname' => '127.0.0.1',
+  'hostname' => '203.0.113.2',
   'timestamp' => '1390264938',
   'status' => '0',
   'format' => '1',
@@ -1804,7 +1804,7 @@
   'uid' => '0',
   'subject' => 'The second comment.',
   'comment' => 'The second comment body.',
-  'hostname' => '127.0.0.1',
+  'hostname' => '203.0.113.3',
   'timestamp' => '1390264948',
   'status' => '1',
   'format' => '1',
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
index 6d6cc49..8c96dae 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
@@ -2512,7 +2512,7 @@
   'nid' => '1',
   'uid' => '1',
   'subject' => 'A comment',
-  'hostname' => '::1',
+  'hostname' => '2001:db8:ffff:ffff:ffff:ffff:ffff:ffff',
   'created' => '1421727536',
   'changed' => '1421727536',
   'status' => '1',
