Next: , Up: IP Library   [Contents]


3.1 Link

The (ip link) module introduces procedures to access and modify the network links on your machine. They are equivalent to the ip link family of commands, from iproute2.

Datatype representing the status of a network link.

get-links print-link

<link> make-link link? link-name link-id link-type link-flags link-mtu link-qdisc link-state link-mode link-group link-qlen link-addr link-brd

name

Name of the link, such as "enp1s0".

id

Index of the link, a unique number used to identify the link.

type

Type of the link, as an integer.

flags

Flags associated with the device, as a list of symbols, such as '(UP LOOPBACK).

mtu

MTU of the link, as an integer.

qdisc

Queuing discipline of the link, as a string, such as "noqueue".

state

State of the link, as an integer. Use int->operstate from (netlink constant) to get a symbol, such as IF_OPER_UP.

mode

Mode of the link. 0 means DORMANT, 1 means DEFAULT.

group

Identifier of the group it belongs to. 0 for default.

qlen

Size of the queue.

addr

Ethernet address of the link, as a string.

brd

Broadcast (ethernet) address of the link, as a string.

Returns the list of existing links in the system, as a list of <link> objects.

Display link on the standard output, using a format similar to ip link from iproute2.

Modify an existing link and set its flags and attributes to the ones specified by the various keywords. When a keyword is omited, the corresponding attribute is not changed.

device can be a device index (as a number) or a device name (as a string).

Do not set #:up and #:down at the same time. Do not set *-on and *-off at the same time.

Print the set of devices on standard output. Setting any of the keyword to a non-false value will filter the results to only show results that match the corresponding value. You may set more than one keyword.

Add a new link with given name and type. Additional arguments can be passed to control the state of the link at creation. type-args is an association list containing additional values for the given type.

When type is "vlan", type-args can contain a number associated with 'id: the VLAN id to be created.

When type is "veth", type-args can contain a string associated with 'peer: the name of the peer.

The following is an example in which we create a new veth (virtual ethernet) pair and give them a name:

;; same as "ip l add v0p0 type veth peer v0p1"
(link-add "v0p0" "veth" #:type-args '((peer . "v0p1")))

Delete a link. device can contain the name of the link, as a string, or its index, as a number.


Next: , Up: IP Library   [Contents]