Detecting a change of IP address in Linux

前端 未结 7 1343
轮回少年
轮回少年 2020-12-29 10:53

Does anyone know a way to detect a change of IP address in Linux. Say I have dhcpcd running, and it assigns a new IP address, is there a way I can get a notification when it

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 11:16

    The command

    ip monitor
    

    will show you this kind of thing happening. It uses some the netlink API which is rather tricky and not documented well (at least for humans to understand). However, it is able to get notified by the kernel of various events, such as changes of assigned IPs, routing tables and link status (e.g. someone unplugged the network)

提交回复
热议问题