Add an option called "random" that combined with "ether" can generate a
random MAC address for an Ethernet interface. PR: 211984 Submitted by: pi@ Reviewed by: gnn, cem, jhb, lidl, rpokala, wblock Approved by: wblock (manpages)
This commit is contained in:
parent
f1a6b7cb09
commit
e700bef2dc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=305860
@ -90,13 +90,23 @@ link_getaddr(const char *addr, int which)
|
|||||||
|
|
||||||
if (which != ADDR)
|
if (which != ADDR)
|
||||||
errx(1, "can't set link-level netmask or broadcast");
|
errx(1, "can't set link-level netmask or broadcast");
|
||||||
if ((temp = malloc(strlen(addr) + 2)) == NULL)
|
if (!strcmp(addr, "random")) {
|
||||||
errx(1, "malloc failed");
|
sdl.sdl_len = sizeof(sdl);
|
||||||
temp[0] = ':';
|
sdl.sdl_alen = ETHER_ADDR_LEN;
|
||||||
strcpy(temp + 1, addr);
|
sdl.sdl_nlen = 0;
|
||||||
sdl.sdl_len = sizeof(sdl);
|
sdl.sdl_family = AF_LINK;
|
||||||
link_addr(temp, &sdl);
|
arc4random_buf(&sdl.sdl_data, ETHER_ADDR_LEN);
|
||||||
free(temp);
|
/* Non-multicast and claim it is a hardware address */
|
||||||
|
sdl.sdl_data[0] &= 0xfc;
|
||||||
|
} else {
|
||||||
|
if ((temp = malloc(strlen(addr) + 2)) == NULL)
|
||||||
|
errx(1, "malloc failed");
|
||||||
|
temp[0] = ':';
|
||||||
|
strcpy(temp + 1, addr);
|
||||||
|
sdl.sdl_len = sizeof(sdl);
|
||||||
|
link_addr(temp, &sdl);
|
||||||
|
free(temp);
|
||||||
|
}
|
||||||
if (sdl.sdl_alen > sizeof(sa->sa_data))
|
if (sdl.sdl_alen > sizeof(sa->sa_data))
|
||||||
errx(1, "malformed link-level address");
|
errx(1, "malformed link-level address");
|
||||||
sa->sa_family = AF_LINK;
|
sa->sa_family = AF_LINK;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
|
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd June 8, 2016
|
.Dd September 17, 2016
|
||||||
.Dt IFCONFIG 8
|
.Dt IFCONFIG 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -145,6 +145,12 @@ is specified as a series of colon-separated hex digits.
|
|||||||
This can be used to, for example,
|
This can be used to, for example,
|
||||||
set a new MAC address on an Ethernet interface, though the
|
set a new MAC address on an Ethernet interface, though the
|
||||||
mechanism used is not Ethernet specific.
|
mechanism used is not Ethernet specific.
|
||||||
|
Use the
|
||||||
|
.Pq Dq random
|
||||||
|
keyword to set a randomly generated MAC address.
|
||||||
|
A randomly-generated MAC address might be the same as one already in use
|
||||||
|
in the network.
|
||||||
|
Such duplications are extremely unlikely.
|
||||||
If the interface is already
|
If the interface is already
|
||||||
up when this option is used, it will be briefly brought down and
|
up when this option is used, it will be briefly brought down and
|
||||||
then brought back up again in order to ensure that the receive
|
then brought back up again in order to ensure that the receive
|
||||||
@ -254,7 +260,7 @@ Display subnet masks in dotted quad notation, for example:
|
|||||||
.br
|
.br
|
||||||
255.255.0.0 or 255.255.255.192
|
255.255.0.0 or 255.255.255.192
|
||||||
.It Sy hex
|
.It Sy hex
|
||||||
Display subnet masks in hexidecimal, for example:
|
Display subnet masks in hexadecimal, for example:
|
||||||
.br
|
.br
|
||||||
0xffff0000 or 0xffffffc0
|
0xffff0000 or 0xffffffc0
|
||||||
.El
|
.El
|
||||||
@ -2759,7 +2765,7 @@ interface to send the frame directly to the remote host instead of
|
|||||||
broadcasting the frame to the multicast group.
|
broadcasting the frame to the multicast group.
|
||||||
This is the default.
|
This is the default.
|
||||||
.It Fl vxlanlearn
|
.It Fl vxlanlearn
|
||||||
The forwarding table is not populated by recevied packets.
|
The forwarding table is not populated by received packets.
|
||||||
.It Cm vxlanflush
|
.It Cm vxlanflush
|
||||||
Delete all dynamically-learned addresses from the forwarding table.
|
Delete all dynamically-learned addresses from the forwarding table.
|
||||||
.It Cm vxlanflushall
|
.It Cm vxlanflushall
|
||||||
|
Loading…
Reference in New Issue
Block a user