Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried adding route add -net netmask dev eth0 to my Fedora rc.local file, but it's not being executed when Fedora boots up. What can I do to fix this?

update: i changed to the full path cmd in my rc.local /sbin/route add -net netmask dev eth0 but its not being executed. I change it to sudo /sbin/route add -net netmask dev eth0 it still doesnt work although it works when i manually enter it in the terminal.

share|improve this question
I have been working over it and it looks the executing sequence is not as it should be, since systemd like to up system quickly it does not bother about if network service is up or not (specially in case of route adding). I am facing same problem but going to try loading rc-local.service after the network service. – Muhammad Arif Jul 6 '12 at 14:34

Here is the step by step configuration:

Step 1

In /etc create symbolic link

lrwxrwxrwx   1 root     root         18 Jun 29 19:08 rc.local -> /etc/rc.d/rc.local

In /etc/rc.d create rc.local file

/sbin/route add -net netmask gw

Make rc.local executable, your rc.local file should look like

-rwxr-xr-x    1 root root    93 Jul  4 18:30 rc.local

Step 2

cd /lib/systemd/system
ls -l rc-local.service

-rw-r--r-- 1 root root 565 Jul  6 20:18 rc-local.service

Edit rc-local.service, your rc-local.service file should look like as under:

Description=/etc/rc.local Compatibility

ExecStart=/etc/rc.d/rc.local start
share|improve this answer

You should add full path to route command, /sbin/route add should work.

share|improve this answer
Always use the full path for any commands in scripts. During part of the boot the $PATH is not yet set. in cron files your $PATH will also be diferent from your normal login. – Sibster Apr 2 '12 at 11:24

Likely, rc.local simply is not being executed at boot. You can verify this by running systemctl status rc-local.service. If it was not executed, you'll see output like this:

rc-local.service - /etc/rc.d/rc.local Compatibility
          Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static)
          Active: inactive (dead)
          CGroup: name=systemd:/system/rc-local.service

If it was executed successfully at boot, you'll instead see output like this:

rc-local.service - /etc/rc.d/rc.local Compatibility
          Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static)
          Active: active (exited) since Sun, 01 Apr 2012 12:54:47 -0700; 1 day and 21h ago
        Main PID: 380 (code=exited, status=0/SUCCESS)
          CGroup: name=systemd:/system/rc-local.service

If it's not being executed a boot, you've likely hit a common pitfall. Traditionally, Red Hat systems placed this file in /etc/rc.d/rc.local, with a symlink at /etc/rc.local for people familiar with Debian systems. Recent versions of Fedora do not include the rc.local file by default, to speed up boot slightly by not having to execute bash on what is on most systems an empty file. systemd now checks to see whether /etc/rc.d/rc.local exists and is executable, and only executes it if it is.

If you created the file at /etc/rc.local, you'll need to move or symlink it to /etc/rc.d/rc.local for it to be executed on boot. You should also verify that it is executable, (chmod +x /etc/rc.d/rc.local).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .