ip_address_label
Manage ip address labels on a remote server in ruby
linux manual
Actions
name | description |
---|---|
list | List address labels. |
add | Add an address label. |
delete | Delete an address label |
flush | Flush all address labels in the kernel |
List
List the current address label entries in the kernel.
Result
Returns an array of IPAddressLabel
structs.
IPAddressLabel Fields
Field | Type | Description |
---|---|---|
address |
string
|
(IPv4 or IPv6) address attached to a network device. |
prefixlen |
integer
|
The number of bits in the netmask |
label |
integer
|
The label for the prefix. |
Example
host.ip('addrlabel', 'list').to_a
[
[0] #<Struct:Kanrisuru::Core::IP::IPAddressLabel:0x000006e0
address = "::1",
label = 0,
prefix_length = 128
>,
[1] #<Struct:Kanrisuru::Core::IP::IPAddressLabel:0x00000730
address = "::",
label = 3,
prefix_length = 96
>,
[2] #<Struct:Kanrisuru::Core::IP::IPAddressLabel:0x00000780
address = "::ffff:0.0.0.0",
label = 4,
prefix_length = 96
>,
[3] .. [6],
[7] #<Struct:Kanrisuru::Core::IP::IPAddressLabel:0x00000910
address = "fec0::",
label = 11,
prefix_length = 10
>,
[8] #<Struct:Kanrisuru::Core::IP::IPAddressLabel:0x00000960
address = "fc00::",
label = 5,
prefix_length = 7
>,
[9] #<Struct:Kanrisuru::Core::IP::IPAddressLabel:0x000009b0
address = "::",
label = 1,
prefix_length = 0
>
]
Add
Add an address label entry to the kernel.
This command needs escalated privileges to make changes to certain files and directory ownership.
Parameters
Field | Type | Description |
---|---|---|
prefix |
string
|
The IP prefix identifies the number of significant bits used to identify a network. |
dev |
string
|
The outbound interface. |
label |
integer
|
Numeric label for the prefix. |
Result
No explicit data struct returned, only option is success?
, failure?
, and status
to see if the program exited properly.
Example
host.su('root')
result = host.ip('addrlabel', 'add', dev: 'ens3', prefix: '2001:6f8:12d8:2::/64', label: 200)
result.success?
true
Delete
Delete an address label entry from the kernel.
This command needs escalated privileges to make changes to certain files and directory ownership.
Parameters
Coincide with the arguments of add but the label is not required.
Result
No explicit data struct returned, only option is success?
, failure?
, and status
to see if the program exited properly.
Example
host.su('root')
result = host.ip('addrlabel', 'del', dev: 'ens3', prefix: '2001:6f8:12d8:2::/64')
result.success?
true
Flush
Flush all address labels in the kernel. This does not restore any default settings.
Result
No explicit data struct returned, only option is success?
, failure?
, and status
to see if the program exited properly.
Example
host.su('root')
result = host.ip('addrlabel', 'flush')
result.success?
true