我想在 FreeBSD(来宾操作系统/虚拟机)启动过程的某个时刻删除分配给 Linux 主机操作系统(Devuan 5)上的 tap0 的 IP 地址(169.254.149.209),创建如下 udev 规则:
/etc/udev/rules.d/01-flush-tap0.rules:
KERNEL=="tap0", ACTION=="add", RUN+="/bin/bash -c '/bin/sleep 5; /sbin/ip a fl dev tap0'"
我已经用以下命令激活了它:
udevadm trigger
我什至重新启动并启动了 freeebd 虚拟机。不幸的是tap0的IP并没有消失。也许下面的日志消息可以帮助您了解原因?
[ 86.952262] bridge: filtering via arp/ip/ip6tables is no longer available by
default. Update your scripts to load br_netfilter if you need this.
[ 88.828606] br1: port 1(tap0) entered blocking state [ 88.828627] br1: port 1(tap0) entered disabled state
[ 88.828941] device tap0 entered promiscuous mode
[ 88.829104] br1: port 1(tap0) entered blocking state [ 88.829119] br1: port 1(tap0) entered forwarding state
不管怎样,看看下面的规则:
70-persistent-net.rules :
This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# USB device 0x:0x (usb)
SUBSYSTEM=="net", ACTION=="add",DRIVERS=="?*",ATTR{address}=="00:60:70:01:00:bf",
ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
它使用SUBSYSTEM==“net”,但我使用KERNEL==“tap0”。我不确定 KERNEL=="tap0" 是否正确。我怀疑 SUBSYSTEM=="net" 更好......或者?你知道错误在哪里吗?