撤消一些网络设置,包括“promisc”模式

撤消一些网络设置,包括“promisc”模式

假设我有以下脚本,它大致设置了 promisc 模式并在两个网络之间设置了一个桥梁(在某种意义上充当 mac 级别的路由点)。

## set interfaces to promiscuous mode
ifconfig eth0 0.0.0.0 promisc up
ifconfig eth1 0.0.0.0 promisc up

## add both interfaces to the virtual bridge network
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth1

## optional: configure an ip to the bridge to allow remote access
ifconfig br0 192.168.0.111 netmask 255.255.255.0 up
route add default gw 192.168.0.1 dev br0

脚本已被查看这里

假设我需要再次“关闭”混杂模式(创建另一个脚本来将其关闭)或返回以前的配置,有没有什么巧妙的方法来实现这一点?

答案1

您不应该再使用ifconfigroute(因为它们在 Linux 中已被弃用多年,并且不再默认安装在现代 Linux 系统上)并且应该重写它们以使用当前ip命令。

之后,你可以使用以下命令禁用混杂模式:

ip link set eth0 promisc off

相关内容