Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid setting default gateway on Linux #561

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/ports/linux/set_network_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ SET_VALUES_PERMANENTLY=$6
# name as station name internally.
SKIP_SETTING_HOSTNAME=true

# The default gateway is typically used for non-Profinet traffic
SKIP_SETTING_DEFAULT_GATEWAY=true

echo "Network script for ${INTERFACE}: " \
"Set IP ${IP_ADDRESS} " \
"Netmask ${NETMASK} " \
"Gateway ${DEFAULT_GATEWAY} " \
"Permanent: ${SET_VALUES_PERMANENTLY} " \
"Hostname: ${HOSTNAME} " \
"Skip setting hostname: ${SKIP_SETTING_HOSTNAME}"
"Skip setting hostname: ${SKIP_SETTING_HOSTNAME} " \
"Skip setting default gateway: ${SKIP_SETTING_DEFAULT_GATEWAY}"

# There is no need to set the changes permanently,
# as the p-net stack will set the IP parameters on each start.
Expand All @@ -64,13 +68,15 @@ if ! ip link set dev $INTERFACE up; then
exit 1
fi

if [ "${DEFAULT_GATEWAY}" != "0.0.0.0" ]; then
if ! ip route add default via $DEFAULT_GATEWAY; then
echo "Failed to set default gateway"
exit 1
if [ "$SKIP_SETTING_DEFAULT_GATEWAY" = false ]; then
if [ "${DEFAULT_GATEWAY}" != "0.0.0.0" ]; then
if ! ip route add default via $DEFAULT_GATEWAY; then
echo "Failed to set default gateway"
exit 1
fi
else
echo "No valid default gateway given. Skipping setting default gateway."
fi
else
echo "No valid default gateway given. Skipping setting default gateway."
fi

if [ "$SKIP_SETTING_HOSTNAME" = false ]; then
Expand Down
Loading