send_arp命令 - Linux man page

本文深入探讨了send_arp工具的使用,该工具用于在网络设备上发送ARP广播,报告虚拟IP地址的变更。适用于集群服务器监控服务状态、更新ARP缓存或发送周期性广播。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Name

send_arp - tool to notify network of a new IP address / MAC address mapping

Synopsis

send_arp takes the supplied data and sends it out as an arp broadcast on the specified network device. This tool is mostly used by software (such aspiranha) that manipulates virtual IP addresses and needs to notify the network that the device servicing an IP address has changed.

send_arp [-i ARG"] old-ip-addr old-mac-addr new-ip-addr new-mac-addr"

Description

send_arp sends out an arp broadcast on the specified network device (defaults to eth0), reporting an old and new IP address mapping to a MAC address.This is most useful in situations involving virtual IP addresses, where the network device servicing that address has changed, and other network arp cachesneed to be notified about it. All the data is specified in the command line and is simply passed along in an arp message frame. Since the old and new dataspecified can contain the same information, this tool can also be used to refresh arp caches or send periodic broadcasts.

send_arp simply takes the specified arguments and places them in an ethernet arp broadcast.is a daemon used by pulse to monitor the runningstatus of the specified services on clustered servers. This tool has NO error checking and should not be run without the direct supervision ofpulse!

Options

-i ARG

Optional. Indicates the network device to send the arp broadcast on. If omitted, the program defaults to eth0.

old-ip-addr
The original IP address (specified in nnn.nnn.nnn.nnn format) that the MAC address specified in "old-mac-addr" had mapped to it.
old-mac-addr
The MAC address that was servicing the IP address specified in "old-ip-addr". The MAC address is specified in hex, and can be formatted with or withoutcolon (":") separators.
new-ip-addr
The new IP address (specified in nnn.nnn.nnn.nnn format) that the MAC address specified in "new-mac-addr" now has mapped to it.
new-mac-addr
The MAC address that is now servicing the IP address specified in "new-ip-addr". The MAC address is specified in hex, and can be formatted with or withoutcolon (":") separators.
### 关于 `arpchk_send_arp_byif` 函数 在网络编程领域,ARP (Address Resolution Protocol) 协议用于将IP地址解析为对应的MAC地址。函数 `arpchk_send_arp_byif` 主要应用于发送 ARP 请求报文来获取目标设备的 MAC 地址。 此函数通常定义如下: ```c int arpchk_send_arp_byif(const char *iface, const unsigned char *smac, const unsigned char *sip, const unsigned char *dip); ``` 参数说明: - `iface`: 接口名称字符串,例如 `"eth0"` 或者 `"wlan0"`. - `smac`: 发送方硬件地址(即源MAC地址),长度应为6字节. - `sip`: 发送方协议地址(即源IP地址),对于IPv4来说是一个4字节数组. - `dip`: 目标协议地址(即目的IP地址),同样针对IPv4而言也是四字节数组. 该函数的工作流程大致可以描述为构建并发出一个标准格式的ARP请求包到指定网络接口上,并监听回应以获得所需的映射关系[^1]. 具体实现方面涉及到套接字操作以及数据链路层消息组装等内容,在Linux环境下可以通过PF_PACKET类型的原始套接字完成上述过程。下面给出一段简化版伪代码展示如何调用这个功能: ```c #include <stdio.h> #include <string.h> #include <sys/socket.h> #include <linux/if_packet.h> #include <net/ethernet.h> /* 提供 ETH_P_ARP 定义 */ // ...其他必要的头文件... void send_arp_request(char* interface_name){ int sockfd; struct sockaddr_ll socket_address; // 创建socket sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); memset(&socket_address, 0, sizeof(socket_address)); // 设置sockaddr_ll结构体成员... bind(sockfd , (struct sockaddr*)&socket_address,sizeof(struct sockaddr_ll)); // 构造ARP帧并sendto() ... } ``` 由于提供的参考资料并未涉及具体的 `arpchk_send_arp_byif` 实现细节或使用案例,以上信息基于常规理解和实践总结得出. 对于此类底层网络通信的操作,请务必谨慎处理权限问题及相关法律法规约束。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值