Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I tried adding route add -net 224.0.0.0 netmask 240.0.0.0 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 224.0.0.0 netmask 240.0.0.0 dev eth0 but its not being executed. I change it to sudo /sbin/route add -net 224.0.0.0 netmask 240.0.0.0 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
add comment

3 Answers

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

#!/bin/bash
#!/bin/sh
/sbin/route add -net 192.xxx.xx.x netmask 255.255.255.0 gw 192.xxx.xx.xx

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:

[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
share|improve this answer
add comment

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
add comment

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
add comment

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.