IP address: Difference between revisions

m Text replacement - "<(\/?)source" to "<$1syntaxhighlight"
 
(One intermediate revision by one other user not shown)
Line 9: Line 9:
! Protocol !! using <code>ip</code> options !! "dumb" grep (no options to <code>ip</code>)
! Protocol !! using <code>ip</code> options !! "dumb" grep (no options to <code>ip</code>)
|-
|-
| IPv4 || <source lang="bash">ip -4 addr show | awk '{ print $2 }'</source> ||  <source lang="bash">ip addr show | grep 'inet ' | awk '{ print $2 }'</source>  
| IPv4 || <syntaxhighlight lang="bash">ip -4 addr show | awk '{ print $2 }'</syntaxhighlight> ||  <syntaxhighlight lang="bash">ip addr show | grep 'inet ' | awk '{ print $2 }'</syntaxhighlight>  
|-
|-
| IPv4 and IPv6 ||  || <source lang="bash">ip addr show | grep 'inet' | awk '{ print $2 }'</source>
| IPv4 and IPv6 ||  || <syntaxhighlight lang="bash">ip addr show | grep 'inet' | awk '{ print $2 }'</syntaxhighlight>
|-
|-
| IPv6 || <source lang="bash">ip -6 addr show | awk '{ print $2 }'</source> || <source lang="bash">ip addr show | grep 'inet6' | awk '{ print $2 }'</source>
| IPv6 || <syntaxhighlight lang="bash">ip -6 addr show | awk '{ print $2 }'</syntaxhighlight> || <syntaxhighlight lang="bash">ip addr show | grep 'inet6' | awk '{ print $2 }'</syntaxhighlight>
|}
|}


== External ==
If you're looking for your external IP address instead, simply google "what is my ip?"


If you're looking for your external IP address instead, simply google "what is my ip?"
== Older ==
On older systems you might need to use <code>ifconfig</code>, and specify the <code>/sbin</code> path because it's not in the standard path for regular users on RedHat.
<syntaxhighlight lang="bash">
/sbin/ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | sort -n | awk '{print $1}'
</syntaxhighlight>


[[Category:System Administration]]
[[Category:System Administration]]