I see somewhere people use:
IF_ADDRESS="$(echo "$IP4_ADDRESS_0" | cut -d'/' -f1)"
to get the IP address in a network configuration script. In my system, I create a script under the directory
/etc/network/if-up.d/ and test with:
echo "$IP4_ADDRESS_0" >> /tmp/test.log
but get nothing with this variable. What's wrong?
/etc/network/interfaces is like this:
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
My final purpose is to set up the IP routing policy with a script like this.