Top | ![]() |
![]() |
![]() |
![]() |
NMSettingIPConfigNMSettingIPConfig — Abstract base class for IPv4 and IPv6 addressing, routing, and name service properties |
GPtrArray * | addresses | Read / Write |
gint | dad-timeout | Read / Write / Construct |
gchar * | dhcp-hostname | Read / Write |
gboolean | dhcp-send-hostname | Read / Write / Construct |
gint | dhcp-timeout | Read / Write |
GStrv | dns | Read / Write |
GStrv | dns-options | Read / Write |
gint | dns-priority | Read / Write / Construct |
GStrv | dns-search | Read / Write |
gchar * | gateway | Read / Write |
gboolean | ignore-auto-dns | Read / Write / Construct |
gboolean | ignore-auto-routes | Read / Write / Construct |
gboolean | may-fail | Read / Write / Construct |
gchar * | method | Read / Write |
gboolean | never-default | Read / Write / Construct |
gint64 | route-metric | Read / Write / Construct |
guint | route-table | Read / Write |
GPtrArray * | routes | Read / Write |
GBoxed ├── NMIPAddress ╰── NMIPRoute GObject ╰── NMSetting ╰── NMSettingIPConfig ├── NMSettingIP4Config ╰── NMSettingIP6Config
NMSettingIPConfig is the abstract base class of NMSettingIP4Config and NMSettingIP6Config, providing properties related to IP addressing, routing, and Domain Name Service.
NMIPAddress * nm_ip_address_new (int family
,const char *addr
,guint prefix
,GError **error
);
Creates a new NMIPAddress object.
family |
the IP address family ( |
|
addr |
the IP address |
|
prefix |
the address prefix length |
|
error |
location to store error, or |
NMIPAddress * nm_ip_address_new_binary (int family
,gconstpointer addr
,guint prefix
,GError **error
);
Creates a new NMIPAddress object. addr
must point to a buffer of the
correct size for family
.
family |
the IP address family ( |
|
addr |
the IP address |
|
prefix |
the address prefix length |
|
error |
location to store error, or |
void
nm_ip_address_ref (NMIPAddress *address
);
Increases the reference count of the object.
void
nm_ip_address_unref (NMIPAddress *address
);
Decreases the reference count of the object. If the reference count reaches zero, the object will be destroyed.
gboolean nm_ip_address_equal (NMIPAddress *address
,NMIPAddress *other
);
Determines if two NMIPAddress objects contain the same address and prefix (attributes are not compared).
NMIPAddress *
nm_ip_address_dup (NMIPAddress *address
);
Creates a copy of address
int
nm_ip_address_get_family (NMIPAddress *address
);
Gets the IP address family (eg, AF_INET) property of this address object.
const char *
nm_ip_address_get_address (NMIPAddress *address
);
Gets the IP address property of this address object.
void nm_ip_address_set_address (NMIPAddress *address
,const char *addr
);
Sets the IP address property of this address object.
addr
must be a valid address of address
's family. If you aren't sure you
have a valid address, use nm_utils_ipaddr_valid()
to check it.
void nm_ip_address_get_address_binary (NMIPAddress *address
,gpointer addr
);
Gets the IP address property of this address object.
addr
must point to a buffer that is the correct size for address
's family.
[skip]
void nm_ip_address_set_address_binary (NMIPAddress *address
,gconstpointer addr
);
Sets the IP address property of this address object.
addr
must point to a buffer that is the correct size for address
's family.
[skip]
guint
nm_ip_address_get_prefix (NMIPAddress *address
);
Gets the IP address prefix (ie "24" or "30" etc) property of this address object.
void nm_ip_address_set_prefix (NMIPAddress *address
,guint prefix
);
Sets the IP address prefix property of this address object.
char **
nm_ip_address_get_attribute_names (NMIPAddress *address
);
Gets an array of attribute names defined on address
.
GVariant * nm_ip_address_get_attribute (NMIPAddress *address
,const char *name
);
Gets the value of the attribute with name name
on address
the value of the attribute with name name
on
address
, or NULL
if address
has no such attribute.
[transfer none]
void nm_ip_address_set_attribute (NMIPAddress *address
,const char *name
,GVariant *value
);
Sets or clears the named attribute on address
to the given value.
address |
the NMIPAddress |
|
name |
the name of an address attribute |
|
value |
the value. |
[transfer none][allow-none] |
NMIPRoute * nm_ip_route_new (int family
,const char *dest
,guint prefix
,const char *next_hop
,gint64 metric
,GError **error
);
Creates a new NMIPRoute object.
NMIPRoute * nm_ip_route_new_binary (int family
,gconstpointer dest
,guint prefix
,gconstpointer next_hop
,gint64 metric
,GError **error
);
Creates a new NMIPRoute object. dest
and next_hop
(if non-NULL
) must
point to buffers of the correct size for family
.
void
nm_ip_route_ref (NMIPRoute *route
);
Increases the reference count of the object.
void
nm_ip_route_unref (NMIPRoute *route
);
Decreases the reference count of the object. If the reference count reaches zero, the object will be destroyed.
gboolean nm_ip_route_equal (NMIPRoute *route
,NMIPRoute *other
);
Determines if two NMIPRoute objects contain the same destination, prefix, next hop, and metric. (Attributes are not compared.)
gboolean nm_ip_route_equal_full (NMIPRoute *route
,NMIPRoute *other
,guint cmp_flags
);
Determines if two NMIPRoute objects contain the same destination, prefix, next hop, and metric.
Since: 1.10
int
nm_ip_route_get_family (NMIPRoute *route
);
Gets the IP address family (eg, AF_INET) property of this route object.
const char *
nm_ip_route_get_dest (NMIPRoute *route
);
Gets the IP destination address property of this route object.
void nm_ip_route_set_dest (NMIPRoute *route
,const char *dest
);
Sets the destination property of this route object.
dest
must be a valid address of route
's family. If you aren't sure you
have a valid address, use nm_utils_ipaddr_valid()
to check it.
void nm_ip_route_get_dest_binary (NMIPRoute *route
,gpointer dest
);
Gets the destination property of this route object.
dest
must point to a buffer that is the correct size for route
's family.
[skip]
void nm_ip_route_set_dest_binary (NMIPRoute *route
,gconstpointer dest
);
Sets the destination property of this route object.
dest
must point to a buffer that is the correct size for route
's family.
[skip]
guint
nm_ip_route_get_prefix (NMIPRoute *route
);
Gets the IP prefix (ie "24" or "30" etc) of this route.
void nm_ip_route_set_prefix (NMIPRoute *route
,guint prefix
);
Sets the prefix property of this route object.
const char *
nm_ip_route_get_next_hop (NMIPRoute *route
);
Gets the IP address of the next hop of this route; this will be NULL
if the
route has no next hop.
void nm_ip_route_set_next_hop (NMIPRoute *route
,const char *next_hop
);
Sets the next-hop property of this route object.
next_hop
(if non-NULL
) must be a valid address of route
's family. If you
aren't sure you have a valid address, use nm_utils_ipaddr_valid()
to check
it.
gboolean nm_ip_route_get_next_hop_binary (NMIPRoute *route
,gpointer next_hop
);
Gets the next hop property of this route object.
next_hop
must point to a buffer that is the correct size for route
's family.
[skip]
void nm_ip_route_set_next_hop_binary (NMIPRoute *route
,gconstpointer next_hop
);
Sets the destination property of this route object.
next_hop
(if non-NULL
) must point to a buffer that is the correct size for
route
's family.
[skip]
gint64
nm_ip_route_get_metric (NMIPRoute *route
);
Gets the route metric property of this route object; lower values indicate "better" or more preferred routes; -1 indicates "default" (meaning NetworkManager will set it appropriately).
void nm_ip_route_set_metric (NMIPRoute *route
,gint64 metric
);
Sets the metric property of this route object.
char **
nm_ip_route_get_attribute_names (NMIPRoute *route
);
Gets an array of attribute names defined on route
.
GVariant * nm_ip_route_get_attribute (NMIPRoute *route
,const char *name
);
Gets the value of the attribute with name name
on route
the value of the attribute with name name
on
route
, or NULL
if route
has no such attribute.
[transfer none]
void nm_ip_route_set_attribute (NMIPRoute *route
,const char *name
,GVariant *value
);
Sets the named attribute on route
to the given value.
route |
the NMIPRoute |
|
name |
the name of a route attribute |
|
value |
the value. |
[transfer none][allow-none] |
const NMVariantAttributeSpec *const *
nm_ip_route_get_variant_attribute_spec
(void
);
Since: 1.8
gboolean nm_ip_route_attribute_validate (const char *name
,GVariant *value
,int family
,gboolean *known
,GError **error
);
Validates a route attribute, i.e. checks that the attribute is a known one and the value is of the correct type and well-formed.
Since: 1.8
const char *
nm_setting_ip_config_get_method (NMSettingIPConfig *setting
);
the “method” property of the setting; see NMSettingIP4Config and NMSettingIP6Config for details of the methods available with each type.
guint
nm_setting_ip_config_get_num_dns (NMSettingIPConfig *setting
);
const char * nm_setting_ip_config_get_dns (NMSettingIPConfig *setting
,int idx
);
gboolean nm_setting_ip_config_add_dns (NMSettingIPConfig *setting
,const char *dns
);
Adds a new DNS server to the setting.
void nm_setting_ip_config_remove_dns (NMSettingIPConfig *setting
,int idx
);
Removes the DNS server at index idx
.
gboolean nm_setting_ip_config_remove_dns_by_value (NMSettingIPConfig *setting
,const char *dns
);
Removes the DNS server dns
.
void
nm_setting_ip_config_clear_dns (NMSettingIPConfig *setting
);
Removes all configured DNS servers.
guint
nm_setting_ip_config_get_num_dns_searches
(NMSettingIPConfig *setting
);
const char * nm_setting_ip_config_get_dns_search (NMSettingIPConfig *setting
,int idx
);
gboolean nm_setting_ip_config_add_dns_search (NMSettingIPConfig *setting
,const char *dns_search
);
Adds a new DNS search domain to the setting.
void nm_setting_ip_config_remove_dns_search (NMSettingIPConfig *setting
,int idx
);
Removes the DNS search domain at index idx
.
gboolean nm_setting_ip_config_remove_dns_search_by_value (NMSettingIPConfig *setting
,const char *dns_search
);
Removes the DNS search domain dns_search
.
void
nm_setting_ip_config_clear_dns_searches
(NMSettingIPConfig *setting
);
Removes all configured DNS search domains.
guint
nm_setting_ip_config_get_num_dns_options
(NMSettingIPConfig *setting
);
Since: 1.2
gboolean
nm_setting_ip_config_has_dns_options (NMSettingIPConfig *setting
);
NMSettingIPConfig can have a list of dns-options. If the list is empty, there are two similar (but differentiated) states. Either the options are explicitly set to have no values, or the options are left undefined. The latter means to use a default configuration, while the former explicitly means "no-options".
const char * nm_setting_ip_config_get_dns_option (NMSettingIPConfig *setting
,guint idx
);
Since: 1.2
int nm_setting_ip_config_next_valid_dns_option (NMSettingIPConfig *setting
,guint idx
);
the index, greater or equal than idx
, of the first valid
DNS option, or -1 if no valid option is found
Since: 1.2
gboolean nm_setting_ip_config_add_dns_option (NMSettingIPConfig *setting
,const char *dns_option
);
Adds a new DNS option to the setting.
Since: 1.2
void nm_setting_ip_config_remove_dns_option (NMSettingIPConfig *setting
,int idx
);
Removes the DNS option at index idx
.
Since: 1.2
gboolean nm_setting_ip_config_remove_dns_option_by_value (NMSettingIPConfig *setting
,const char *dns_option
);
Removes the DNS option dns_option
.
Since: 1.2
void nm_setting_ip_config_clear_dns_options (NMSettingIPConfig *setting
,gboolean is_set
);
Removes all configured DNS options.
setting |
||
is_set |
the dns-options can be either empty or unset (default). Specify how to clear the options. |
Since: 1.2
int
nm_setting_ip_config_get_dns_priority (NMSettingIPConfig *setting
);
Since: 1.4
guint
nm_setting_ip_config_get_num_addresses
(NMSettingIPConfig *setting
);
NMIPAddress * nm_setting_ip_config_get_address (NMSettingIPConfig *setting
,int idx
);
gboolean nm_setting_ip_config_add_address (NMSettingIPConfig *setting
,NMIPAddress *address
);
Adds a new IP address and associated information to the setting. The given address is duplicated internally and is not changed by this function.
void nm_setting_ip_config_remove_address (NMSettingIPConfig *setting
,int idx
);
Removes the address at index idx
.
gboolean nm_setting_ip_config_remove_address_by_value (NMSettingIPConfig *setting
,NMIPAddress *address
);
Removes the address address
.
void
nm_setting_ip_config_clear_addresses (NMSettingIPConfig *setting
);
Removes all configured addresses.
const char *
nm_setting_ip_config_get_gateway (NMSettingIPConfig *setting
);
guint
nm_setting_ip_config_get_num_routes (NMSettingIPConfig *setting
);
NMIPRoute * nm_setting_ip_config_get_route (NMSettingIPConfig *setting
,int idx
);
gboolean nm_setting_ip_config_add_route (NMSettingIPConfig *setting
,NMIPRoute *route
);
Appends a new route and associated information to the setting. The
given route is duplicated internally and is not changed by this function.
If an identical route (considering attributes as well) already exists, the
route is not added and the function returns FALSE
.
Note that before 1.10, this function would not consider route attributes and not add a route that has an existing route with same dest/prefix,next_hop,metric parameters.
void nm_setting_ip_config_remove_route (NMSettingIPConfig *setting
,int idx
);
Removes the route at index idx
.
gboolean nm_setting_ip_config_remove_route_by_value (NMSettingIPConfig *setting
,NMIPRoute *route
);
Removes the first matching route that matches route
.
Note that before 1.10, this function would only compare dest/prefix,next_hop,metric
and ignore route attributes. Now, route
must match exactly.
void
nm_setting_ip_config_clear_routes (NMSettingIPConfig *setting
);
Removes all configured routes.
gint64
nm_setting_ip_config_get_route_metric (NMSettingIPConfig *setting
);
Returns the value contained in the “route-metric” property.
the route metric that is used for routes that don't explicitly specify a metric. See “route-metric” for more details.
guint32
nm_setting_ip_config_get_route_table (NMSettingIPConfig *setting
);
Returns the value contained in the “route-table” property.
Since: 1.10
gboolean
nm_setting_ip_config_get_ignore_auto_routes
(NMSettingIPConfig *setting
);
Returns the value contained in the “ignore-auto-routes” property.
gboolean
nm_setting_ip_config_get_ignore_auto_dns
(NMSettingIPConfig *setting
);
Returns the value contained in the “ignore-auto-dns” property.
const char *
nm_setting_ip_config_get_dhcp_hostname
(NMSettingIPConfig *setting
);
Returns the value contained in the “dhcp-hostname” property.
gboolean
nm_setting_ip_config_get_dhcp_send_hostname
(NMSettingIPConfig *setting
);
Returns the value contained in the “dhcp-send-hostname” property.
TRUE
if NetworkManager should send the machine hostname to the
DHCP server when requesting addresses to allow the server to automatically
update DNS information for this machine.
gboolean
nm_setting_ip_config_get_never_default
(NMSettingIPConfig *setting
);
Returns the value contained in the “never-default” property.
gboolean
nm_setting_ip_config_get_may_fail (NMSettingIPConfig *setting
);
Returns the value contained in the “may-fail” property.
TRUE
if this connection doesn't require this type of IP
addressing to complete for the connection to succeed.
int
nm_setting_ip_config_get_dad_timeout (NMSettingIPConfig *setting
);
Since: 1.2
int
nm_setting_ip_config_get_dhcp_timeout (NMSettingIPConfig *setting
);
Returns the value contained in the “dhcp-timeout” property.
Since: 1.2
#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
#define NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname"
#define NM_SETTING_DNS_OPTION_SINGLE_REQUEST_REOPEN "single-request-reopen"
“addresses”
property“addresses” GPtrArray *
Array of IP addresses.
[type GPtrArray(NMIPAddress)]
Flags: Read / Write
“dad-timeout”
property“dad-timeout” gint
Timeout in milliseconds used to check for the presence of duplicate IP addresses on the network. If an address conflict is detected, the activation will fail. A zero value means that no duplicate address detection is performed, -1 means the default value (either configuration ipvx.dad-timeout override or zero). A value greater than zero is a timeout in milliseconds.
The property is currently implemented only for IPv4.
Flags: Read / Write / Construct
Allowed values: [-1,30000]
Default value: -1
Since: 1.2
“dhcp-hostname”
property“dhcp-hostname” gchar *
If the “dhcp-send-hostname” property is TRUE
, then the
specified name will be sent to the DHCP server when acquiring a lease.
This property and “dhcp-fqdn” are mutually exclusive and
cannot be set at the same time.
Flags: Read / Write
Default value: NULL
“dhcp-send-hostname”
property“dhcp-send-hostname” gboolean
If TRUE
, a hostname is sent to the DHCP server when acquiring a lease.
Some DHCP servers use this hostname to update DNS databases, essentially
providing a static hostname for the computer. If the
“dhcp-hostname” property is NULL
and this property is
TRUE
, the current persistent hostname of the computer is sent.
Flags: Read / Write / Construct
Default value: TRUE
“dhcp-timeout”
property“dhcp-timeout” gint
A timeout for a DHCP transaction in seconds.
Flags: Read / Write
Allowed values: >= 0
Default value: 0
“dns-options”
property“dns-options” GStrv
Array of DNS options as described in man 5 resolv.conf.
NULL
means that the options are unset and left at the default.
In this case NetworkManager will use default options. This is
distinct from an empty list of properties.
Flags: Read / Write
Since: 1.2
“dns-priority”
property“dns-priority” gint
DNS servers priority.
The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to 50 for VPNs and 100 for other connections.
Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile.
When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, the one with an active default route will be preferred. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least a negative priority, only DNS servers from connections with the lowest priority value will be used.
When using a DNS resolver that supports split-DNS as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored.
Flags: Read / Write / Construct
Default value: 0
Since: 1.4
“dns-search”
property“dns-search” GStrv
Array of DNS search domains. Domains starting with a tilde ('~') are considered 'routing' domains and are used only to decide the interface over which a query must be forwarded; they are not used to complete unqualified host names.
Flags: Read / Write
“gateway”
property“gateway” gchar *
The gateway associated with this configuration. This is only meaningful if “addresses” is also set.
Flags: Read / Write
Default value: NULL
“ignore-auto-dns”
property“ignore-auto-dns” gboolean
When “method” is set to "auto" and this property to
TRUE
, automatically configured nameservers and search domains are
ignored and only nameservers and search domains specified in the
“dns” and “dns-search” properties, if
any, are used.
Flags: Read / Write / Construct
Default value: FALSE
“ignore-auto-routes”
property“ignore-auto-routes” gboolean
When “method” is set to "auto" and this property to
TRUE
, automatically configured routes are ignored and only routes
specified in the “routes” property, if any, are used.
Flags: Read / Write / Construct
Default value: FALSE
“may-fail”
property“may-fail” gboolean
If TRUE
, allow overall network configuration to proceed even if the
configuration specified by this property times out. Note that at least
one IP configuration must succeed or overall network configuration will
still fail. For example, in IPv6-only networks, setting this property to
TRUE
on the NMSettingIP4Config allows the overall network configuration
to succeed if IPv4 configuration fails but IPv6 configuration completes
successfully.
Flags: Read / Write / Construct
Default value: TRUE
“method”
property“method” gchar *
IP configuration method.
NMSettingIP4Config and NMSettingIP6Config both support "auto", "manual", and "link-local". See the subclass-specific documentation for other values.
In general, for the "auto" method, properties such as “dns” and “routes” specify information that is added on to the information returned from automatic configuration. The “ignore-auto-routes” and “ignore-auto-dns” properties modify this behavior.
For methods that imply no upstream network, such as "shared" or "link-local", these properties must be empty.
For IPv4 method "shared", the IP subnet can be configured by adding one manual IPv4 address or otherwise 10.42.x.0/24 is chosen. Note that the shared method must be configured on the interface which shares the internet to a subnet, not on the uplink which is shared.
Flags: Read / Write
Default value: NULL
“never-default”
property“never-default” gboolean
If TRUE
, this connection will never be the default connection for this
IP type, meaning it will never be assigned the default route by
NetworkManager.
Flags: Read / Write / Construct
Default value: FALSE
“route-metric”
property“route-metric” gint64
The default metric for routes that don't explicitly specify a metric. The default value -1 means that the metric is chosen automatically based on the device type. The metric applies to dynamic routes, manual (static) routes that don't have an explicit metric setting, address prefix routes, and the default route. Note that for IPv6, the kernel accepts zero (0) but coerces it to 1024 (user default). Hence, setting this property to zero effectively mean setting it to 1024. For IPv4, zero is a regular value for the metric.
Flags: Read / Write / Construct
Allowed values: [-1,4294967295]
Default value: -1
“route-table”
property“route-table” guint
Enable policy routing (source routing) and set the routing table used when adding routes.
This affects all routes, including device-routes, IPv4LL, DHCP, SLAAC, default-routes and static routes. But note that static routes can individually overwrite the setting by explicitly specifying a non-zero routing table.
If the table setting is left at zero, it is eligible to be overwritten via global configuration. If the property is zero even after applying the global configuration value, policy routing is disabled for the address family of this connection.
Policy routing disabled means that NetworkManager will add all routes to the main table (except static routes that explicitly configure a different table). Additionally, NetworkManager will not delete any extraneous routes from tables except the main table. This is to preserve backward compatibility for users who manage routing tables outside of NetworkManager.
Flags: Read / Write
Default value: 0
Since: 1.10
“routes”
property“routes” GPtrArray *
Array of IP routes.
[type GPtrArray(NMIPRoute)]
Flags: Read / Write