IPUPDATE: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
Include as part of the netup.sh script so that when a dynamic IP address change happens, the system keeps working | Include as part of the netup.sh script so that when a dynamic IP address change happens, the system keeps working. | ||
<pre> | <pre> | ||
Line 51: | Line 51: | ||
echo -n "$CURGW" > /root/scripts/IPINFO/gateway | echo -n "$CURGW" > /root/scripts/IPINFO/gateway | ||
ipsec setup restart | |||
</pre> | </pre> |
Latest revision as of 18:33, 30 September 2020
Include as part of the netup.sh script so that when a dynamic IP address change happens, the system keeps working.
#!/bin/sh if [[ ! -d /root/scripts/IPINFO ]]; then mkdir -p /root/scripts/IPINFO fi if [ -e /root/scripts/IPINFO/ipaddr ]; then OLDIP=$(cat /root/scripts/IPINFO/ipaddr) else OLDIP="" fi if [ -e /root/scripts/IPINFO/bcast ]; then OLDBC=$(cat /root/scripts/IPINFO/bcast) else OLDBC="" fi if [ -e /root/scripts/IPINFO/gateway ]; then OLDGW=$(cat /root/scripts/IPINFO/gateway) else OLDGW="" fi while [[ ! -n $CURIP || ! -n $CURBC || ! -n $CURGW ]]; do CURIP=$(ip addr show dev eth0 | grep inet | head -1 | cut -f 6 -d " " | cut -f 1 -d \/) CURBC=$(ip addr show dev eth0 | grep inet | head -1 | cut -f 8 -d " " | cut -f 1 -d \/) CURGW=$(ip route | grep default | cut -f 3 -d " ") sleep 3 done if [[ $CURIP != $OLDIP ]]; then for i in /root/scripts/iptables-restore /etc/ipsec.conf /etc/ipsec.secrets /etc/xl2tpd/xl2tpd.conf; do sed -i s/$OLDIP/$CURIP/g $i; done fi if [[ $CURBC != $OLDBC ]]; then for i in /root/scripts/iptables-restore /etc/ipsec.conf /etc/xl2tpd/xl2tpd.conf; do sed -i s/$OLDBC/$CURBC/g $i; done fi if [[ $CURGW != $OLDGW ]]; then for i in /root/scripts/iptables-restore /etc/ipsec.conf /etc/xl2tpd/xl2tpd.conf; do sed -i s/$OLDGW/$CURGW/g $i; done fi echo -n "$CURIP" > /root/scripts/IPINFO/ipaddr echo -n "$CURBC" > /root/scripts/IPINFO/bcast echo -n "$CURGW" > /root/scripts/IPINFO/gateway ipsec setup restart