Tuesday, October 21, 2025

Bulk creation of host objects for import into cisco ASA

 Work in a cisco FMC environment, the FMC has a simple means for importing list of entries.

For host entries, the file must have the following header at the top of the file:

NAME,DESCRIPTION,TYPE,VALUE,LOOKUP


The script takes a list of space-separated entries and applies the header 


#!/bin/bash

# source of files separated by "space"

# hosts.txt

#

filename="fixedup.txt"

#

#convert source.file to UPPERCASE

HDR="NAME,DESCRIPTION,TYPE,VALUE,LOOKUP"

 

# Prompt for a Upper or Lower Case

read -p "Please enter your 'lcase' for lower-case OR 'ucase' for upper-case: " case

# Prompt for a name of source file

read -p "Please enter your source filename: " fileloc

 

< $fileloc  dd conv=$case  >fixedup.txt

#

#

IFS=' '

#

#

while read -r hostname ipv4; do

echo "$hostname,,,$ipv4,"  >> importme.txt

done < "$filename"

 

sed -i '1i\'"$HDR" "importme.txt"


Creating an import file can help with the  mass creation of entries.  




NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \