Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
find out ip addr change with dhcpcd-run-hooks
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 543
Location: Cracow, Poland

PostPosted: Fri Jan 23, 2015 4:19 pm    Post subject: find out ip addr change with dhcpcd-run-hooks Reply with quote

Hello,
I need some kind automatically notification when dhcpd assign new IP adders to wireless interface.
Asking google it turn out, that dhcpcd-run-hooks can be usefull in this matter, but not sure how to started.

http://roy.marples.name/man/html8/dhcpcd-run-hooks.html
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Tue Jan 27, 2015 10:38 am    Post subject: Reply with quote

Just to give an idea

Code:

cat /etc/dhcpcd.exit-hook

showip()
{
        # Report new IP address
        # RA and DHCP6 can assign >1 address but we only report the first one.

        if [ -n "$new_ip_address" ]; then
                echo "$new_ip_address"
        elif [ -n "$new_ra1_addr" ]; then
                echo "$new_ra1_addr"
        elif [ -n "$new_ra1_prefix" ]; then
                echo "$new_ra1_prefix"
        elif [ -n "$new_dhcp6_ia_na1_ia_addr1" ]; then
                echo "$new_dhcp6_ia_na1_ia_addr1"
        elif [ -n "$new_delegated_dhcp6_prefix" ]; then
                echo "$new_delegated_dhcp6_prefix"
        else
                return 1
        fi
}

newip=$(showip)
if [ -n "$newip" ]; then
        echo "$interface: assigned new IP $newip" >>/tmp/newip
fi


So the new ip addresses added will be logged into /tmp/newip.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum