Running a script on addition/removal of an iface

Posted by: drakino

Running a script on addition/removal of an iface - 01/04/2003 22:36

Ok, long story short, my firewall script and pptp connection hate eachother. I connect my pptp connection,and the firewall begins blocking everything until it is restarted. I disconnect, and the same problem occurs. I've poked and prodded at the issue for a few hours, and at this point just want a quick fix, since the box is being replaced/reloaded in under a month. So, how can I have my Linux machine run a script the instant it sees a new interface appear, or disappear? I would do it manually, but the problem is that at times, I connect the PPTP session remotely, and cannot get the firewall script to run again if the connection drops without warning.
Posted by: genixia

Re: Running a script on addition/removal of an ifa - 01/04/2003 22:44

Which distro? There are some variances

But if on RH/Mandrake, check out /etc/sysconfig/network-scripts
Posted by: Daria

Re: Running a script on addition/removal of an ifa - 01/04/2003 23:23

RedHat 7.ancient seems to run /sbin/if{up,down}-local with arguments including the interface name.
Posted by: drakino

Re: Running a script on addition/removal of an ifa - 01/04/2003 23:32

Sorry, forgot that part. SuSE 7.2. Can't see anything like /etc/sysconfig/network-scripts, or if scripts.
Posted by: wfaulk

Re: Running a script on addition/removal of an ifa - 02/04/2003 07:52

If you're using pppd to make your pptp connection (I've seen some that work this way ages ago -- don't know if it's still the case), then you should be able to use up and down scripts to deal with it.

Read your pppd man page and look at the end at the ``SCRIPTS'' section. You should be able to whip up a quick ip-up script that checks to see if $IFNAME is the correct one, and, if so, restart your firewall.
Posted by: drakino

Re: Running a script on addition/removal of an ifa - 02/04/2003 10:25

Bitt, that actually uncovered the problem for me. The ppp scripts were running the firewall wrongly when a pptp, or incoming pptp connection was run. Since the machine has no modem, and no need of ppp beyond pptp, I simply commented out the lines trying to stop and start the firewall.

I have never dialed up with Linux, so all the PPP interfaces are new to me.