Skip to content

Commit

Permalink
network: add DNS Server as params for network
Browse files Browse the repository at this point in the history
when creating network in podman set possibility
to add DNS server as well.

Signed-off-by: Douglas Landgraf <[email protected]>
  • Loading branch information
dougsland committed Jul 6, 2024
1 parent fb9aa46 commit 4d04ba7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
17 changes: 17 additions & 0 deletions constants
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ CGROUP_USED_CONTROLLERS=("memory", "cpu", "io")
############ END - Cgroup definitions ###############################
######################################################################

######################################################################
############ START - Network ##########################
######################################################################

######################################################################
# Description
# Set DNS Server as param when creating a new podman network
# NETWORK_DNS_SERVER="8.8.8.8"
######################################################################

######################################################################
############ STOP - Network ##########################
######################################################################

######################################################################
############ START - SELinux ##########################
Expand Down Expand Up @@ -338,3 +351,7 @@ fi
if [ -z "${SERVICE_MUST_BE_DISABLED+x}" ]; then
SERVICE_MUST_BE_DISABLED=""
fi

if [ -z "${NETWORK_DNS_SERVER+x}" ]; then
NETWORK_DNS_SERVER="8.8.8.8"
fi
14 changes: 10 additions & 4 deletions network
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,22 @@ create_network() {
echo -e "INFO: creating network ${NETWORK_NAME}"
fi

if ! podman network create "${NETWORK_NAME}" 1> /dev/null; then
echo -e "FAIL: unable to create network ${NETWORK_NAME}"
# Check if NETWORK_DNS_INFO is provided and construct the DNS parameters
DNS_PARAMS=""
if [ -n "$NETWORK_DNS_SERVER" ]; then
for DNS in "${NETWORK_DNS_SERVER}"; do
DNS_PARAMS+="--dns $DNS "
done
fi
if ! podman network create ${DNS_PARAMS} ${NETWORK_NAME} 1> /dev/null; then
echo -e "FAIL: unable to create network ${NETWORK_NAME} ${DNS_PARAMS}"
return 1
#exit 255
fi

if [[ "$VERBOSE" = "${FEATURE_ENABLED}" ]]; then
echo -e "PASS: network ${NETWORK_NAME} created."
fi
return 0
#exit 0
}

# Function to remove a network
Expand Down

0 comments on commit 4d04ba7

Please sign in to comment.