Next: Addr, Up: IP Library [Contents][Index]
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.
Wait until a link called name (a string such as "ens3"
) shows
up.
When blocking? is false, use a non-blocking socket and cooperate via
current-read-waiter
—useful when using Fibers.
Display link on the standard output, using a format similar to
ip link
from iproute2
.
#f
] [#:down #f
] [#:type #f
] [#:arp-on #f
] [#:arp-off #f
] [#:dynamic-on #f
] [#:dynamic-off #f
] [#:multicast-on #f
] [#:multicast-off #f
] [#:allmulticast-on #f
] [#:allmulticast-off #f
] [#:promisc-on #f
] [#:promisc-off #f
] [#:trailers-on #f
] [#:trailers-off #f
] [#:carrier-on #f
] [#:carrier-off #f
] [#:txqueuelen #f
] [#:name #f
] [#:address #f
] [#:broadcast #f
] [#:mtu #f
] [#:netns #f
] ¶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.
#f
] [#:group #f
] [#:up #f
] [#:master #f
] [#:vrf #f
] [#:type #f
] ¶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 and a link name associated with
"link"
: the name of the link on which the vlan is created.
The following is an example in which we create a new vlan link:
;; same as "ip l add link eth0 name eth0.7 type vlan id 7" (link-add "eth0.7" "vlan" #:type-args '((id . 7) (link . "eth0")))
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: Addr, Up: IP Library [Contents][Index]