Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Every time I restart my OpenVPN tunnel it increments interface's number and breaks MRTG graph for the interface.

IF-MIB::ifName.76 = STRING: tun_w

after restart:

IF-MIB::ifName.77 = STRING: tun_w

Any way to fix it?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Write a script that regenerates your MRTG configuration whenever the interface is restarted. Also, adjust your MRTG configuration to target an interface based on the IP address. Specifcally if you use cfgmaker to build your config, then pass the --ifref=ip option, assuming your IP is consistent. If your IP isn't consistent, then check the man page other ifref options to see if any apply to your setup.

What if conf files are edited by hand?

In your main configuration file you have created by hand use the include directive to include another configuration file. Something like Include: vpn-interface.cfg. Then update that configuration fragment with a script that happens on start/restart of the VPN.

Since you are using OpenVPN your might use the OpenVPN options --up-restart, --up, --ipchange, and --down options to link into the script that updates the configuration file for that VPN.

Compose your script that runs whenever the interface

share|improve this answer
    
and if conf files are edited by hand? –  Alex May 7 '12 at 4:14

When you create your MRTG cfg file, do not identify the interface by number. Instead, identify it by ifName or similar.

For example this identifies the device by ifName,

Target[tun_w]: #tun_w:public@router

If the ifName is not unique, then try by ifDescr (use a backstroke to escape any spaces or colons in the description):

Target[tun_w]: \tun_w:public@router

Alternatively, use ifType (prefix with %) or Ethernet address (prefix with !)

One of these should allow you to uniquely identify the interface despite its ifIndex changing frequently.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.