Next: , Previous: , Up: IP Library   [Contents][Index]


3.2 Addr

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

Scheme Procedure: addr-add device cidr [#:ipv6? #f] [#:peer (cidr->addr cidr)] [#:broadcast #f] [#:anycast #f] [#:label #f] [#:scope 'global] [#:metric #f] [#:home? #f] [#:mngtmpaddr? #f] [#:nodad? #f] [optimistic? #f] [noprefixroute? #f] [#:autojoin? #f]

Add the address given in cidr to device. device can contain the name of the link, as a string, or its index, as a number.

cidr must be a string containing the address and prefix length, in CIDR notation (addr/prefix).

(addr-add "enp1s0" "192.0.2.15/24")

If you wish to add an IPv6 address instead, set #:ipv6 to #t, as in the following example.

(addr-add "enp1s0" "2001:db8::1a4c/64" #:ipv6? #t)

Note that using the wrong ip type with the wrong value for the #:ipv6? flag will result in a Bad address exception from inet-pton.

Additional flags are available; they follow the same semantics as Iproute2. For pointopoint interfaces, you can specify the address of the remote endpoint with #:peer. You can specify a broadcast or anycast address with #:broadcast and #:anycast. All three require an IP address passed as a string when specified.

You can specify a label for the address with #:label. The parameter must be a string that is either the name of the device, or starts with the name of the device, followed by a colon and must contain at most 15 characters.

You can specify a scope with #:scope, whose value is either 'global, 'link, 'host or a numeric value.

You can specify the priority of the prefix route associated with this address using #:metric, a number.

Finally, this procedures accepts address configuration flags, whose values are booleans. They are unset by default. Some flags only work for IPv6 addresses, those are #:home? to designate this address as the “home address”, #:mngtmpaddr?, #:nodad? and #:optimistic?. The flags #:noprefixroute? and #:autojoin? can be set for IPv4 and IPv6 addresses.

Scheme Procedure: addr-del device cidr [#:ipv6? #f] [#:peer (cidr->addr cidr)] [#:broadcast #f] [#:anycast #f] [#:label #f] [#:scope 'global] [#:metric #f] [#:home? #f] [#:mngtmpaddr? #f] [#:nodad? #f] [optimistic? #f] [noprefixroute? #f] [#:autojoin? #f]

Delete the address given in cidr from device. device can contain the name of the link, as a string, or its index, as a number.

cidr must be a string containing the address and prefix length, in CIDR notation (addr/prefix).

(addr-del "enp1s0" "192.0.2.15/24")

If you wish to remove an IPv6 address instead, set #:ipv6 to #t, as in the following example.

(addr-del "enp1s0" "2001:db8::1a4c/64" #:ipv6? #t)

Note that using the wrong ip type with the wrong value for the #:ipv6? flag will result in a Bad address exception from inet-pton.

Additional flags are available, see the description in addr-add for more details.

Scheme Procedure: addr-show [device]

Print the list of addresses for each device on standard output. Setting device to a link name or link identifier will restrict the output to addresses of that device.


Next: Route, Previous: Link, Up: IP Library   [Contents][Index]