OK, going slowly and explicitly so you know I'm not sneaking in an "erase your system drive" command
:
- Open the Terminal application.
- Type
whoamiand hit Return to check your short username. - Type
sudo visudo /private/etc/sudoers.d/ifconfig, hit Return, enter your macOS account password, hit Return -- that launches the special sudo file editor and creates a new file called "ifconfig" in the "sudoers.d" directory. sudo reads any file in there as well as the main file, and that directory is where user additions should sensibly be put. - Type
Ito put visudo into editing mode. - Type your short username, a space, then
ALL=NOPASSWD: /sbin/ifconfig-- that means "for the user username, from any host, sudo doesn't need a password to run /sbin/ifconfig". So your line will look something like:
⠀⠀exampleuser ALL=NOPASSWD: /sbin/ifconfig - Hit the
ESCkey to get out of editing mode. - Type
:wqand hit Return to write the file and quit visudo.
You should now be able to test by typing sudo ifconfig -a and listing your interfaces without entering a password. This will work because KM runs shell commands in the current user space, ie as you, as you can check by making a simple macro with this action:
Before you get too slap-happy with the sudoers file, remember that various commands require you to authenticate for a reason!
Try to allow as little as possible, if only because an authentication request reminds you that you're about to do something important and gives you a chance to check/reconsider

