Select Your Language

Infrastructure and Management

Cloud Computing

Storage

Runtimes

Integration and Automation

  • Comments
  • %post configuration in Kickstart of network isnt being retained

    Posted on

    I am using a kickstart that assigns dhcp to the network (network --bootproto=dhcp --device=ens192 --noipv6)but in the %post portion of my kickstart I am running a script to set a static IP address. After rebooting the server to complete installation the NetworkManager is defaulting back to DHCP instead of the static information i had set previously. Is there something I am missing in the %post or is there something else I should be doing to get the static ip information to remain in networkmanager? Below is my post section and I changed the IPs. If i throw everything in %post into a .sh file it runs flawlessly in my live environment.
    %post

    !/bin/bash

    Get the current IP address of ens192 assigned by DHCP

    IP_ADDR=$(ip addr show dev ens192 | grep "inet " | grep -v "inet6"| awk '{print $2}' | cut -d/ -f1)

    Extract the first three octets to detect the subnet (e.g., 192.168.1, 10.0.0)

    SUBNET=$(echo $IP_ADDR | cut -d. -f1,2,3)

    Define static IP, gateway, and DNS settings based on subnet detection

    case $SUBNET in
    "")
    STATIC_IP="10.0.2.83"
    GATEWAY="10.0.2.1"
    DNS="10.0.2.81"
    ;;
    *)
    # Default IP settings if the subnet doesn't match any predefined options
    STATIC_IP="10.0.1.83"
    GATEWAY="10.0.1.1"
    DNS="10.0.1.81"
    ;;
    esac

    Configure the static IP settings using nmcli (NetworkManager CLI)

    nmcli con mod ens192 ipv4.addresses $STATIC_IP/24
    nmcli con mod ens192 ipv4.gateway $GATEWAY
    nmcli con mod ens192 ipv4.dns "$DNS"
    nmcli con mod ens192 ipv4.method manual

    Bring the network connection up to apply changes

    nmcli device reapply ens192
    nmcli con down ens192
    nmcli con up ens192
    %end

    by

    points

    Responses

    Red Hat LinkedIn YouTube Facebook X, formerly Twitter

    Quick Links

    Help

    Site Info

    Related Sites

    © 2025 Red Hat, Inc.