Skip to content

Instantly share code, notes, and snippets.

@jeffmccune
Created September 16, 2020 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffmccune/6653b1b4c4b0a206b934d065f13dac64 to your computer and use it in GitHub Desktop.
Save jeffmccune/6653b1b4c4b0a206b934d065f13dac64 to your computer and use it in GitHub Desktop.
Stub IP to troubleshoot dhclient
#! /bin/bash
if ! [[ -f /jeff/ip ]]; then
mkdir /jeff
mv /sbin/ip /jeff/ip
fi
cat <<"EOF" > /sbin/ip
#! /bin/bash
#
read -a st < /proc/$$/stat
read -a ppid < /proc/${st[3]}/stat
file=$(printf '/tmp/%06d_' $$)
/jeff/ip route list table all > ${file}_01_before.txt
echo "ip $@" > ${file}_02_command.txt
/jeff/ip "$@"
rval=$?
echo "rval=${rval}" > ${file}_03_rval.txt
/jeff/ip route list table all > ${file}_04_after.txt
# Write the checklist
echo " * [ ] \`$0 $*\` [**PID=${$}** PPID=${st[3]} ${ppid[1]}] (rval=${rval}) " >> /tmp/jeff.txt
exit $rval
EOF
chmod a+x /sbin/ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment