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

I create some script for a static route, called "my.rc.route" and i put it on /etc/rc.local, so everytime the server get restarted the script shall run after all the startup process.

I feel a bit strange to find there were some line on my script being skipped by the system, randomly.

Anyone deal with this situation? Where to track/ log to read?

I paste my "my.rc.route" here, answered Gnudiff.

#!/bin/bash
ip ro add table arieluna 10.254.254.248/29 dev lan  proto kernel  scope link  src 10.254.254.254
ip ro add table arieluna 10.222.23.0/24 dev vlan17  proto kernel  scope link  src 10.222.23.1
ip ro add table arieluna 10.222.22.0/24 dev vlan16  proto kernel  scope link  src 10.222.22.1
ip ro add table arieluna 10.222.21.0/24 dev vlan15  proto kernel  scope link  src 10.222.21.1
ip ro add table arieluna 10.222.20.0/24 dev vlan14  proto kernel  scope link  src 10.222.20.1
ip ro add table arieluna 10.222.19.0/24 dev vlan13  proto kernel  scope link  src 10.222.19.1
ip ro add table arieluna 10.222.18.0/24 dev vlan12  proto kernel  scope link  src 10.222.18.1
ip ro add table arieluna 10.222.17.0/24 dev vlan11  proto kernel  scope link  src 10.222.17.1
ip ro add table arieluna 10.222.16.0/24 dev vlan10  proto kernel  scope link  src 10.222.16.1
ip ro add table arieluna 10.222.24.0/24 dev vlan18  proto kernel  scope link  src 10.222.24.1
share|improve this question
3  
can you post the script? –  Gnudiff Sep 4 '10 at 16:27
1  
Run it with sh -vx so it's easier to debug it. –  Cristian Ciupitu Sep 4 '10 at 18:08
    
Make sure you set the PATH or use full paths, the usuak problem is that your enviroment isn't right –  Zoredache Sep 4 '10 at 18:18
    
@Cristian Ciupitu, When it run from the prompt, it's run normal great, but thanks! i forget that we can do "man sh" :) –  Ta Coen Sep 4 '10 at 20:09
1  
What exactly do you mean when you say a line is being randomly skipped? Which line is it? How do you know its being skipped? For example, could you be trying to run a command on a network interface that's not up yet? –  Andrew M. Sep 5 '10 at 2:53

1 Answer 1

up vote 1 down vote accepted

@Redmumba is on the right path here. If you try to add iptables rules for interfaces that aren't configured/up yet, then iptables will throw an error and the rules doesn't get added. This sounds to me like you are configuring at least one of your interfaces through NetworkManager or something similar (depends on your distro) and that part only happens when the user logs in through the GUI (i.e. after rc.local is executed).

If you want this to work, you would need to execute the script through an "up" command in /etc/network/interfaces (of you are on a Debian based distro) or similar mechanisms.

Alternatively you could configure your interfaces to be configured at boot time. Under Debian based distros, this is done by replacing the "allow-hotplug" keyword in the interface stanzas with "auto". Other distros will use other mechanisms for that, you would have to read the relevant man pages to find out what to do.

share|improve this answer
    
Thanks all for pointing that out. I run a bridge on vlan, and at the boot time some of bridge interfaces still in disable state. I remove the bridge interfaces and the problems gone. –  Ta Coen Sep 6 '10 at 5:46

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.