Linux SysAdmin Tips & Tricks

Get IP of Primary ethernet

Written by bkarankar

to get the IP of primary ethernet, from where your traffic is going out. run this command

ifconfig $(route -n |awk ‘/0[.]0[.]0[.]0/{print $NF;exit}’) | awk ‘/inet/{print $2}’

About the author

bkarankar

Leave a Comment