Você pode adicionar as chamadas ao gancho post-up
quando a interface é ativada. o
configuração de interface fica em /etc/network/interfaces
. Aqui um exemplo:
auto eth1
iface eth1 inet dhcp
post-up route del -net 10.1.2.0 netmask 255.255.255.0
post-up route add -host 10.1.2.51 eth1
post-up route add -host 10.1.2.52 eth1
pre-down route add -net 10.1.2.0 netmask 255.255.255.0
pre-down route add -host 10.1.2.51 eth1
pre-down route add -host 10.1.2.52 eth1
post-up
command
Run command after bringing the interface up. If this command fails then ifup aborts, refraining from marking the interface as configured (even though it has really been configured), prints an error message, and exits with status 0.pre-down
command
Run command before taking the interface down. If this command fails then ifdown aborts, marks the interface as deconfigured (even though it has not really been deconfigured), and exits with status 0.
Além disso, no Linux, as "net-tools" route
estão obsoletas e devem ser substituídas
pelas ferramentas do pacote iproute2 .
Leitura adicional: