Get the Remote address IP by Magento 2 with a simple code snippet,
<?php
public function __construct(
\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
) {
$this->_remoteAddress = $remoteAddress;
}
public function getRemoteAddress(){
$remoteAddress = $this->_remoteAddress->getRemoteAddress();
return $remoteAddress;
}
Call function in template file by below way,
echo $this->getRemoteAddress();
