Suse Equivalent of rc.local - Suse

This is a discussion on Suse Equivalent of rc.local - Suse ; I am trying to have a simple script to execute a static arp table every time the computer boot up. In Madriva, I did this by adding the following to the rc.local file /sbin/arp -a 192.168.20.20 00:40:b0:c1:f6:c1 /sbin/arp -a 192.168.20.21 ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Suse Equivalent of rc.local

  1. Suse Equivalent of rc.local

    I am trying to have a simple script to execute a static arp table
    every time the computer boot up.

    In Madriva, I did this by adding the following to the rc.local file
    /sbin/arp -a 192.168.20.20 00:40:b0:c1:f6:c1
    /sbin/arp -a 192.168.20.21 00:b4:c8:f1:d0:e6

    In suse 10.2, the nearest thing I can find to rc.local is
    /etc/init.d/boot.local

    When I add the entries to this file and reboot, I check the arp table
    by opening a konsole box and typing /sbin/arp-a

    It fails every time. I then noticed that I can't add static arp
    entries even from the console unless I su to root first.

    In Madriva, this was a simple task, but I find myself frustrated by
    Suse. I like Suse 10.2, and would rather stick with it. Does anyone
    know how I can accomplish this in Suse 10.2?

    Thanks!

  2. Re: Suse Equivalent of rc.local

    On 2007-06-15 01:26, meuban@gmail.com wrote:
    > I am trying to have a simple script to execute a static arp table
    > every time the computer boot up.
    >
    > In Madriva, I did this by adding the following to the rc.local file
    > /sbin/arp -a 192.168.20.20 00:40:b0:c1:f6:c1
    > /sbin/arp -a 192.168.20.21 00:b4:c8:f1:d0:e6
    >
    > In suse 10.2, the nearest thing I can find to rc.local is
    > /etc/init.d/boot.local
    >
    > When I add the entries to this file and reboot, I check the arp table
    > by opening a konsole box and typing /sbin/arp-a
    >
    > It fails every time. I then noticed that I can't add static arp
    > entries even from the console unless I su to root first.
    >
    > In Madriva, this was a simple task, but I find myself frustrated by
    > Suse. I like Suse 10.2, and would rather stick with it. Does anyone
    > know how I can accomplish this in Suse 10.2?
    >
    > Thanks!


    Can't you just add it to /etc/ethers ?

    My manual for arp say:
    arp -s hostname hw_addr

    But, All my stuff listen to my dhcp server, so I really have no
    experiences about building arp tables by hand.

    If you think it's annoying to use su , you can just add to /etc/sudoers:
    meuban ALL = (ALL) NOPASSWD: ALL

    And use sudo arpscript if you cant find some good place to put it.



    /birre

  3. Re: Suse Equivalent of rc.local

    On Fri, 15 Jun 2007 17:22:54 +0200, birre
    wrote:

    >On 2007-06-15 01:26, meuban@gmail.com wrote:
    >> I am trying to have a simple script to execute a static arp table
    >> every time the computer boot up.
    >>
    >> In Madriva, I did this by adding the following to the rc.local file
    >> /sbin/arp -a 192.168.20.20 00:40:b0:c1:f6:c1
    >> /sbin/arp -a 192.168.20.21 00:b4:c8:f1:d0:e6
    >>
    >> In suse 10.2, the nearest thing I can find to rc.local is
    >> /etc/init.d/boot.local
    >>
    >> When I add the entries to this file and reboot, I check the arp table
    >> by opening a konsole box and typing /sbin/arp-a
    >>
    >> It fails every time. I then noticed that I can't add static arp
    >> entries even from the console unless I su to root first.
    >>
    >> In Madriva, this was a simple task, but I find myself frustrated by
    >> Suse. I like Suse 10.2, and would rather stick with it. Does anyone
    >> know how I can accomplish this in Suse 10.2?
    >>
    >> Thanks!

    >
    >Can't you just add it to /etc/ethers ?
    >
    >My manual for arp say:
    >arp -s hostname hw_addr
    >
    >But, All my stuff listen to my dhcp server, so I really have no
    >experiences about building arp tables by hand.
    >
    >If you think it's annoying to use su , you can just add to /etc/sudoers:
    >meuban ALL = (ALL) NOPASSWD: ALL
    >
    >And use sudo arpscript if you cant find some good place to put it.
    >
    >
    >
    >/birre

    Thank you for your advice. The problem with /etc/init.d/boot.local is
    that it runs these scripts before any of the run level scripts are
    executed. Therefore, etho is not setup, and the arp command cannot
    successfully run untill etho has been setup.

    I looked at /etc/ethers. It appears to be what I am after. I
    therefore added the ethernet address and corresponding IPs into
    /etc/ethers. When I reboot and run /sbin/arp -a, the static arp
    entries are still not showing up. I am not sure I understand the
    purpose of /etc/ethers.

  4. Re: Suse Equivalent of rc.local

    On 2007-06-15 21:29, meuban@gmail.com wrote:
    >
    > I looked at /etc/ethers. It appears to be what I am after. I
    > therefore added the ethernet address and corresponding IPs into
    > /etc/ethers. When I reboot and run /sbin/arp -a, the static arp
    > entries are still not showing up. I am not sure I understand the
    > purpose of /etc/ethers.



    I don't understand it either, since I have no problem when all my devices
    get IP from dhcp, and have fixed address from their mac address.
    I was checking rarp, but this was obsoleted , so suse do it some other way.

    What if you just ping the host, don't you get it added in the arp table ?

    /birre

  5. Re: Suse Equivalent of rc.local

    meuban@gmail.com wrote:

    > I am trying to have a simple script to execute a static arp table
    > every time the computer boot up.
    >
    > In Madriva, I did this by adding the following to the rc.local file
    > /sbin/arp -a 192.168.20.20 00:40:b0:c1:f6:c1
    > /sbin/arp -a 192.168.20.21 00:b4:c8:f1:d0:e6
    >
    > In suse 10.2, the nearest thing I can find to rc.local is
    > /etc/init.d/boot.local
    >
    > When I add the entries to this file and reboot, I check the arp table
    > by opening a konsole box and typing /sbin/arp-a
    >
    > It fails every time. I then noticed that I can't add static arp
    > entries even from the console unless I su to root first.
    >
    > In Madriva, this was a simple task, but I find myself frustrated by
    > Suse. I like Suse 10.2, and would rather stick with it. Does anyone
    > know how I can accomplish this in Suse 10.2?
    >
    > Thanks!


    You put your script into /etc/init.d
    Then you put the information needed to tell init when to run it into
    /etc/inittab including the runlevel and possible additional actions such as
    'respawn'.

    In inittab it also has a section pointing to
    /etc/init.d/rc.{0|1|2|3|4|5|6|7}

    But it has become convention in Suse to put the actual script in init.d and
    just a link in the rc.? Much easier when you are looking for these scripts.

    man inittab gives a good explanation of the fields.
    It is probably worth you reading 'man init' too, so that you don't
    accidentally use a reserved runlevel or something.

    Remember to make your script file in init.d controllable in the way others
    are, it could even matter for this particular arp script, you may want to
    temporarily allow your settings to arrive from a dhcp server. If it was a
    company server then I think a future IT person may do a bit of head
    scratching trying to work out where this unexpected static is coming from.

    Each to his own, but remember that statics can be assigned by your dhcp
    server as well as the dynamic addresses. A single place to look for a ip
    assignment problem is really a much nicer way than searching scripts.

    Anyway, I was just about to point you to the skeleton/template script file
    that used to be in init.d, maybe it's the rc skeleton in Redhat I was
    remembering because it doesn't seem to be there anymore, but this is a
    typical one,

    I have put a Skeleton script for init.d at the bottom of this post. Not all
    of the sections are relevant to your 'arp' script, but worth keeping a
    skeleton to hand. In your case a 'stop' could be to remove the assigned
    statics. (sorry to go on about this, but I don't think that the next IT
    person would think of looking into init.d to find where this static is
    coming from, he is going to call you a rude name you mark my words. However
    if it's only for you and no other IT person involved, then could you call
    yourself a rude name, just for the sake of appearences).

    Remember to log actions even if it is only say your script has ran, missing
    log entries are the hardest to find, as they say

    #! /bin/sh
    # Author:
    # Purpose:
    # Date:


    BIN_FILE="/usr/local/sbin/yourscriptOrExecutable"
    CONF_FILE="/etc/yourconffile.conf"
    PID_FILE="/var/run/yourscriptOrExecutable.pid"


    .. /etc/rc.status
    # might need this depending on what your script does
    # rc_reset

    # Check for missing binary
    if [ ! -x ${BIN_FILE} ]; then
    echo -n >&2 "${BIN_FILE} is not installed. "
    rc_status -s
    exit 5
    fi


    case "$1" in
    start)
    echo -n "Starting ${BIN_FILE} "
    if [ ! -f ${CONF_FILE} ]; then
    echo -n >&2 "Configuration file, ${CONF_FILE} does
    not exist. "
    rc_status -s
    exit 6
    fi
    checkproc -p ${PID_FILE} ${BIN_FILE}
    case $? in
    0) echo -n "- Warning: already running. " ;;
    1) echo -n "- Warning: ${PID_FILE} exists. " ;;
    esac
    #main start goes here after any checks you need to make
    rc_status -v
    ;;
    stop)
    echo -n "Stopping ${BIN_FILE} "
    ;;
    try-restart|condrestart)
    ;;
    restart)

    ;;
    reload|rerun)
    echo -n "Reload/Re-run ${BIN_FILE} "
    killproc -p ${PID_FILE} -HUP ${BIN_FILE}
    rc_status -v
    ;;
    status)
    ;;
    *)
    echo "Usage: $0 {list the relevant commands from above
    example - start|stop|...}"
    exit 1
    ;;
    esac
    rc_exit





  6. Re: Suse Equivalent of rc.local

    On Mon, 18 Jun 2007 14:28:48 +0100, BearItAll
    wrote:

    >meuban@gmail.com wrote:
    >
    >> I am trying to have a simple script to execute a static arp table
    >> every time the computer boot up.
    >>
    >> In Madriva, I did this by adding the following to the rc.local file
    >> /sbin/arp -a 192.168.20.20 00:40:b0:c1:f6:c1
    >> /sbin/arp -a 192.168.20.21 00:b4:c8:f1:d0:e6
    >>
    >> In suse 10.2, the nearest thing I can find to rc.local is
    >> /etc/init.d/boot.local
    >>
    >> When I add the entries to this file and reboot, I check the arp table
    >> by opening a konsole box and typing /sbin/arp-a
    >>
    >> It fails every time. I then noticed that I can't add static arp
    >> entries even from the console unless I su to root first.
    >>
    >> In Madriva, this was a simple task, but I find myself frustrated by
    >> Suse. I like Suse 10.2, and would rather stick with it. Does anyone
    >> know how I can accomplish this in Suse 10.2?
    >>
    >> Thanks!

    >
    >You put your script into /etc/init.d
    >Then you put the information needed to tell init when to run it into
    >/etc/inittab including the runlevel and possible additional actions such as
    >'respawn'.
    >
    >In inittab it also has a section pointing to
    >/etc/init.d/rc.{0|1|2|3|4|5|6|7}
    >
    >But it has become convention in Suse to put the actual script in init.d and
    >just a link in the rc.? Much easier when you are looking for these scripts.
    >
    >man inittab gives a good explanation of the fields.
    >It is probably worth you reading 'man init' too, so that you don't
    >accidentally use a reserved runlevel or something.
    >
    >Remember to make your script file in init.d controllable in the way others
    >are, it could even matter for this particular arp script, you may want to
    >temporarily allow your settings to arrive from a dhcp server. If it was a
    >company server then I think a future IT person may do a bit of head
    >scratching trying to work out where this unexpected static is coming from.
    >
    >Each to his own, but remember that statics can be assigned by your dhcp
    >server as well as the dynamic addresses. A single place to look for a ip
    >assignment problem is really a much nicer way than searching scripts.
    >
    >Anyway, I was just about to point you to the skeleton/template script file
    >that used to be in init.d, maybe it's the rc skeleton in Redhat I was
    >remembering because it doesn't seem to be there anymore, but this is a
    >typical one,
    >
    >I have put a Skeleton script for init.d at the bottom of this post. Not all
    >of the sections are relevant to your 'arp' script, but worth keeping a
    >skeleton to hand. In your case a 'stop' could be to remove the assigned
    >statics. (sorry to go on about this, but I don't think that the next IT
    >person would think of looking into init.d to find where this static is
    >coming from, he is going to call you a rude name you mark my words. However
    >if it's only for you and no other IT person involved, then could you call
    >yourself a rude name, just for the sake of appearences).
    >
    >Remember to log actions even if it is only say your script has ran, missing
    >log entries are the hardest to find, as they say
    >
    >#! /bin/sh
    ># Author:
    ># Purpose:
    ># Date:
    >
    >
    >BIN_FILE="/usr/local/sbin/yourscriptOrExecutable"
    >CONF_FILE="/etc/yourconffile.conf"
    >PID_FILE="/var/run/yourscriptOrExecutable.pid"
    >
    >
    >. /etc/rc.status
    ># might need this depending on what your script does
    ># rc_reset
    >
    ># Check for missing binary
    >if [ ! -x ${BIN_FILE} ]; then
    > echo -n >&2 "${BIN_FILE} is not installed. "
    > rc_status -s
    > exit 5
    >fi
    >
    >
    >case "$1" in
    > start)
    > echo -n "Starting ${BIN_FILE} "
    > if [ ! -f ${CONF_FILE} ]; then
    > echo -n >&2 "Configuration file, ${CONF_FILE} does
    >not exist. "
    > rc_status -s
    > exit 6
    > fi
    > checkproc -p ${PID_FILE} ${BIN_FILE}
    > case $? in
    > 0) echo -n "- Warning: already running. " ;;
    > 1) echo -n "- Warning: ${PID_FILE} exists. " ;;
    > esac
    > #main start goes here after any checks you need to make
    > rc_status -v
    > ;;
    > stop)
    > echo -n "Stopping ${BIN_FILE} "
    > ;;
    > try-restart|condrestart)
    > ;;
    > restart)
    >
    > ;;
    > reload|rerun)
    > echo -n "Reload/Re-run ${BIN_FILE} "
    > killproc -p ${PID_FILE} -HUP ${BIN_FILE}
    > rc_status -v
    > ;;
    > status)
    > ;;
    > *)
    > echo "Usage: $0 {list the relevant commands from above
    >example - start|stop|...}"
    > exit 1
    > ;;
    >esac
    >rc_exit
    >
    >
    >

    Thank you to all who have responded to my question. I appreciate your
    time!

  7. Re: Suse Equivalent of rc.local

    On Mon, 18 Jun 2007 12:41:29 +0200, birre
    wrote:

    >On 2007-06-15 21:29, meuban@gmail.com wrote:
    >>
    >> I looked at /etc/ethers. It appears to be what I am after. I
    >> therefore added the ethernet address and corresponding IPs into
    >> /etc/ethers. When I reboot and run /sbin/arp -a, the static arp
    >> entries are still not showing up. I am not sure I understand the
    >> purpose of /etc/ethers.

    >
    >
    >I don't understand it either, since I have no problem when all my devices
    >get IP from dhcp, and have fixed address from their mac address.
    >I was checking rarp, but this was obsoleted , so suse do it some other way.
    >
    >What if you just ping the host, don't you get it added in the arp table ?
    >
    >/birre


    Yes, if I ping a host it always shows up in the arp table. What I am
    trying to accomplish by establishing a static arp table upon boot up
    is security. That is, with a static arp table established, it
    prevents someone from poisoning the arp table (a way of ip
    masquerading).

    Thanks for taking the time to help.

+ Reply to Thread