# Virtual IPs

## Setup

In order to interact with this feature you must first retrieve a particular load balancer, like so:

    $loadBalancer = $service->loadBalancer('{id}');

## List Virtual IPs

You can list the VIPs associated with a load balancer like so:

    $vips = $loadBalancer->virtualIpList();

    foreach ($vips as $vip) {
        /** @var $vip of OpenCloud\LoadBalancer\Resource\VirtualIp **/
    }

## Get existing VIP

To retrieve the details of an existing VIP on a load balancer, you will need its ID:

## Add Virtual IPv6

You can add additional IPv6 VIPs to a load balancer using the following method:

    use OpenCloud\LoadBalancer\Enum\IpType;

    $loadBalancer->addVirtualIp(IpType::PUBLIC, 6);

the first argument is the type of network your IP address will server traffic in - and can either be `PUBLIC` or `PRIVATE`. The second argument is the version of IP address, either `4` or `6`.

## Add Virtual IPv4

Similar to above:

    use OpenCloud\LoadBalancer\Enum\IpType;

    $loadBalancer->addVirtualIp(IpType::PUBLIC, 4);

## Remove Virtual IP

You can remove a VIP from a load balancer.

    $vip->remove();

Note

A load balancer must have at least one VIP associated with it. If you try to remove a load balancer’s last VIP, a `ClientErrorResponseException` will be thrown.