Is there a way to use hostnames in firewall rules rather than ip ? There are some guides in google but wanted to ask here.
I think this would be an hard security issue.Is there a way to use hostnames in firewall rules rather than ip ? There are some guides in google but wanted to ask here.
#!/bin/bash
# Keyword is # Dynu in host.fw file. So change accordingly.
# crontab -e : */30 * * * * sh /updateip.sh
# You can use https://www.dynu.com/ service free.
HOSTNAME=YOUR-DYNAMIC-HOSTNAME
NODENAME=YOUR-NODE-NAME
CURRENTIP=/currentip.log
Current_IP=$(host $HOSTNAME | cut -f4 -d' ')
if [ $CURRENTIP = "" ] ; then
sed -i '/# Dynu/c\IN ACCEPT -source '"$Current_IP"' # Dynu ' /etc/pve/nodes/$NODENAME/host.fw
echo $Current_IP > $CURRENTIP
else
Old_IP=$(cat $CURRENTIP)
if [ "$Current_IP" = "$Old_IP" ] ; then
echo IP address has not changed
else
sed -i '/# Dynu/c\IN ACCEPT -source '"$Current_IP"' # Dynu ' /etc/pve/nodes/$NODENAME/host.fw
echo $Current_IP > $CURRENTIP
echo iptables have been updated
fi
fi
Why? Can you please explain?I think this would be an hard security issue.
I, too, have been using firewalls with FQDNs/hostnames instead of IP addresses in rules for a very long time. It's very convenient. You make a change in the DNS, and it updates everywhere. But what if the DNS server is compromised? Or if the DNS is manipulated in other ways...? If you use only IP addresses, this is irrelevant, at least for this particular use case.Why? Can you please explain?
We use essential cookies to make this site work, and optional cookies to enhance your experience.