Back to Home

interface post-up on CentOS

centos · rhel · post-up · interface · ifup · ifdown · ifup-local · ifdown-local

interface post-up on CentOS

    Half a day tormented on how to get CentOS to execute a certain script after raising the interface. After the first unsuccessful googling of the appearance of the first difficulties, he forced himself, however, not to act on the principle of “Better a dirty hack than a long hemorrhagic”: I refrained from sticking a crutch into /etc/sysconfig/network-scripts/ifup-eth
    Daba and to keep my colleagues from doing this I write the result of my research here.

    1. In its pure form, there is no analogue of the Debian post-up in CentOS. Do not even try to look for him.
    2. All that is is a feature described in Red Hat Knowledgebase DOC-8695

    If in brief: it is proposed to create a certain / sbin / ifup-local. In which then put your useful (or useless) code. For example: But this is not our method. Store something related to the configuration in
    #Set the MTU for eth0 only using the ip command
    if [ "$1" = "eth0" ]; then
    exec /sbin/ip link set dev ${1} mtu 1200
    fi

    /sbin/I consider unobvious, and even criminal in relation to other administrators. Which may have to work with this system in the future.

    3. Described in the article Network Setup in Linux via config files, part 1 directories ifup.dand ifdown.dsimply could not be found. There is not even a mention of them. /etc/sysconfig/network-scripts/*

    Based on 1,2,3, the only correct solution I consider is the placement of /sbin/the ifup-local following content in the script : Accordingly, files are placed in this , etc. with useful code inside. And finally, the situation is similar with running the code before raising the interface ( ), before disabling it ( ) and after disabling it ( ). PS
    #!/bin/bash

    POSTUPNAME="/etc/sysconfig/network-scripts/post-up-$1"
    if [ -x $POSTUPNAME ]; then
    exec $POSTUPNAME
    fi


    /etc/sysconfig/network-scripts/post-up-eth0

    /sbin/ifup-pre-local/sbin/ifdown-pre-local/sbin/ifdown-local

    Work was carried out on CentOS release 5.4 (Final). Not a single server was damaged as a result of the autopsy.

    Read Next