Would there be a way I could write a script that records the dhcp IP's that the computer running Ubuntu obtains everytime it obtains a new IP?
1 Answer
I'm curious as to why you would want to do this...
But this script should do what you want it to do, you just have to run it when the computer is started up but after it gets an IP address
#!/bin/bash
currIP=`ip addr show dev eth0 | awk -F 'inet |/24' ' { print $2 }' | tail -n 1
newIP=`grep $currIP ips.txt | wc -l`
if [[ $present -eq 0 ]]; then
echo $currIP >> ips.txt
fi
Very quick off the top of my head script to do that. It won't check to see whether ips.txt actually exists though.