How to get ip address?

How to get ip address?

I used the following code:

services:
foo:
class: Drupal\MYMODULE\Foo
arguments: [[email protected]']
In MYMODULE/src/Foo.php

namespace Drupal\MYMODULE;

use Symfony\Component\HttpFoundation\...