Allows to add more than one ip address to one network device.
Extracts ip addressess from file using sed. Uses a tag(ip) to grep the IP lines after extracting. Must be a way to just output regex matched on sed. Show Sample Output
GeoIP Needs to be installed. Can be done from some distro's or via MaxMind.com for free. There even is a free city database availabble. If the GeoLiteCity is downloaded and installed it will also find more information
geoiplookup -f /var/lib/GeoIP/GeoLiteCity.dat commandlinefu.com
GeoIP City Edition, Rev 1: US, NJ, Absecon, 08201, 39.420898, -74.497704, 504, 609
Show Sample Output
This command shows a sorted list of the IP addresses from which there have been authentication errors via SSH (possible script kiddies trying to gain access to your server), it eliminates duplicates so it's easier to read, but you can remove the "uniq" command at the end, or even do a "uniq -c" to have a count of how many times each IP address shows in the log (the path to the log may vary from system to system) Show Sample Output
Instead of hard-coding in a check to scrape info from ifconfig based on a specific interface, do it in a more portable way. This works really well if you switch between wired, wireless, bluetooth or even VPN connections. You can get your current IP in a script (since it'll be something like tun0 instead of eth0 or wlan1). This uses a well known public ip address 8.8.8.8, but it doesn't actually connect to it, it just shows you the route it would take. Show Sample Output
May be useful to get user's ip address over the phone, as users struggle to read through a long ipconfig result. Show Sample Output
To show ipv6 instead, use [[ -6 ]] instead of [[ -4 ]]
ip -o -6 a s | awk -F'[ /]+' '$2!~/lo/{print $4}'
To show only the IP of a specific interface, in case you get more than one result:
ip -o -4 a s eth0 | awk -F'[ /]+' '$2!~/lo/{print $4}'
ip -o -4 a s wlan0 | awk -F'[ /]+' '$2!~/lo/{print $4}'
Show Sample Output
Sometimes it's useful to output just the ip address. Or some other information, changing the "ipv4.addresses" in command. The power of awk! Show all possible "greps" with
nmcli connection show [yourInterfaceNameHere]
Show Sample Output
Like the tiltle said, you can use an argument too ( the interface )
MyIps eth0
will show only the IP of this interface and the public IP
( tested with Linux )
You can add that function in ~/.bashrc, then
. ~/.bashrc
Now you are ready to call this function in all your terms...
Show Sample Output
Thanks to comment if that works or not...
If you have already typed that snippet or you know you already have IO::Interface::Simple perl module, you can type only the last command :
perl -e 'use IO::Interface::Simple; my $ip=IO::Interface::Simple->new($ARGV[0]); print $ip->address,$/;' <INTERFACE>
( The first perl command will install the module if it's not there already... )
Prints the unique IP Addresses as they arrive from an Apache `access.log` file. The '-W interactive' tells awk to start writing to stdout immediately and not buffer the output. This command builds on the uniq lines without sorting command (http://www.commandlinefu.com/commands/view/4389/remove-duplicate-entries-in-a-file-without-sorting.)
Request all information about my IP address in json format
Defines a function to geolocate a given IP address; if none supplied, will default to your external IP address. Show Sample Output
Shortest url to a external IP-service, 10 characters. Show Sample Output
Plain Text Ip Output, independent of Layout change. Show Sample Output
I'm not sure how reliable this command is, but it works for my needs. Here's also a variant using grep. nslookup www.example.com | grep "^Address: " | awk '{print $2}' Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: