IP address of a Server.
The UpCloud network has public and private IP addresses. Public addresses are exposed to the Internet, and private addresses are only visible to servers under the same UpCloud account.
When a server is created, UpCloud will assign one private
IPv4
address to the server.
That address can not be released, except by deleting the server, and additional private
addresses
can not be added.
In addition to the private
address, one server can have 1-5 public
addresses assigned to it.
These can be IPv4
or IPv6
addresses.
All IP addresses are always assigned to some server. IP addresses can not be reserved for later use. As soon as an IP address is released, either because the server it was assigned to was deleted, or the IP address was unassigned from a server, the IP address may be reassigned (by UpCloud) to another server.
A list of all IP addresses associated with an UpCloud API user account is available via IP Addresses API.
A list of IP addresses associated with a specific server is available in the Server.ipAddresses property when using the Server details API.
When creating a server, a list of IP addresses can be specified in the Server.ipAddresses property. The list can not be empty.
import static fi.linuxbox.upcloud.resource.Builder.*
def newServer = server {
// skipping mandatory properties and showing only
// optional ipAddresses property:
ipAddresses = [
ipAddress {
access = 'public' // mandatory
family = 'IPv4' // mandatory
// partOfPlan not allowed
// ptrRecond not allowed???
// server not allowed
},
ipAddress {
access = 'public'
family = 'IPv6'
}
]
}
upcloud.create newServer { resp, err ->
...
}
After server creation, additional IP addresses can be assigned to a server. Only family and
server properties are allowed here, since additional private
addresses can not be added.
Note that the server must be stopped while adding IP addresses.
import static fi.linuxbox.upcloud.resource.Builder.*
def additionalAddress = ipAddress {
// access not allowed, since only public addresses can be added
family = 'IPv4' // mandatory
// partOfPlan not allowed
// ptrRecond not allowed???
server = existingServer.uuid // mandatory
}
upcloud.create additionalAddress { resp, err ->
...
}
The only property of an IP address that can be modified is the reverse DNS PTR record.
import fi.linuxbox.upcloud.api.IpAddress
import static fi.linuxbox.upcloud.resource.Builder.ipAddress
def ptrRecord = ipAddress {
ptrRecord = 'hostname.example.com'
}
def ipAddressApi = someIpAddress.withTraits(IpAddress)
ipAddressApi.update ptrRecord { resp, err ->
...
}
While IP addresses of a server are released automatically when a server deleted, IP addresses can also be released one by one (from whatever server they were assigned to).
import fi.linuxbox.upcloud.api.IpAddress
import static fi.linuxbox.upcloud.resource.Builder.ipAddress
def unneededAddress = ipAddress SESSION: session {
address = '10.0.0.1'
}
def ipAddressApi = unneededAddress.withTraits(IPAddress)
ipAddressApi.delete { resp, err ->
assert !err // resp contains headers but not much more
}
Fields inherited from class | Fields |
---|---|
class Resource |
__$stMC |
Type | Name and description |
---|---|
String |
access Whether this IP address is for public or private network. |
String |
address String representation of this IP address. |
String |
family Address family of this IP address, either IPv4 or IPv6 . |
String |
partOfPlan Whether this IP address is included in fixed plan price of the server ( yes ). |
String |
ptrRecord The reverse DNS PTR record for this IP address. |
String |
server The unique identifier of the server to which this IP address is assigned. |
Methods inherited from class | Name |
---|---|
class Resource |
setProperty, getProperty, toString, asType, getMetaClass, setMetaClass, wrapper, propertyMissing, propertyMissing, methodMissing, proj, invokeMethod, this$dist$invoke$1, this$dist$set$1, this$dist$get$1, super$1$toString, getHTTP, getSESSION, getMETA, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll |
class Object |
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Whether this IP address is for public
or private
network.
IPv6
addresses can not be private.
This is available in all IP address related responses. This must be set when creating an IP address as part of server creation. After server creation, this can not be specified when creating additional IP addresses or modifying them.
String representation of this IP address.
Either in dotted decimal notation (for IPv4
family),
or hexadecimal representation (for IPv6
family).
This is available in all IP address related responses. This can not be set when creating or modifying IP addresses, since UpCloud assigns the addresses automatically. This can be used as an identifier, but note that IP addresses are reused after released.
Address family of this IP address, either IPv4
or IPv6
.
IPv6
addresses can not be private.
This is available in all IP address related responses. This must be set when creating an IP address, either as part of server creation or when assigning an additional new address to an existing server. This can not be modified after the creation.
Whether this IP address is included in fixed plan price of the server (yes
).
This is available when listing all IP addresses associated with an UpCloud API account, and when fetching details of a single IP address. This can not be set from client side.
The reverse DNS PTR record for this IP address.
Only public
IP addresses can have a reverse DNS PTR record.
This is available when listing all IP addresses associated with an UpCloud API account, and when fetching details of a single IP address. This is the only property that can be modified.
The unique identifier of the server to which this IP address is assigned.
This is available when listing all IP addresses associated with an UpCloud API account, and when fetching details of a single IP address. This must be specified when assigning an additional new address to an existing server. This is not available in the server details response, and this can not be specified when creating an IP address as part of creating a server, or when modifying an IP address.