Ping With IPv4 Or IPv6

Today we’re going to have a fun article, one easy enough for everyone, where we talk about how to ping with IPv4 or IPv6. You have an option and you get to decide if you want to use IPv4 or IPv6. It’s just a matter of a couple of different flags, so a new user can manage this one.

An IP address is a numerical address assigned to computers, it’s a way to address those computers – meaning to send and receive data. While you normally don’t do much with individual IP addresses, they’re what runs in the background and make this whole networking thing happen.

We had IPv4 and we’re slowly moving to IPv6. We’ve long since run out of IPv4 addresses (though they’re still widely used, often for legacy reasons), but they’re 32-bit addresses while IPv6 is a 128-bit address.

If you’re not good at math:

IPv4 supports 4,294,967,296 addresses.
IPv6 supports 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses.

See the difference?

There was an IPv5 but IPv6 was created before IPv5 was made a standard and so there’s no IPv5 standard. The reasons for this are fairly obvious. After all, IPv6 supports a metric buttload of devices. That’s a seriously big number that we write as 128-bit (2128).

Every human on the planet can have all the addresses they could use, which is important when you consider stuff like IoT (internet of Things) where your home may contain many connected devices in the ‘smart home’ sense of things. We decidedly do not have enough IPv4 addresses for that.

Well, the truth is that we kind of suck at migrating to IPv6. Wh you ping localhost, you’re probably going to see 127.0.0.1. If you’re using IPv6 then you’d see ::1. If there’s any place where we might want to use IPv6, it’s in the home – with all these connected devices.

Even if you don’t have a smart home, smart cameras, a doorbell camera, various routers, a connected refrigerator, or the like, odds are that you’ve got more than one connected device. Fortunately, you still have IPv4 going on and they have some reserved IP addresses to work with. So, you’re good with that – as a general rule.

So, we still use IPv4. Should we? Probably not. But, there are legacy reasons for IPv4 to exist. That shouldn’t include the public web (I don’t believe) but it does. The adoption rate for IPv6 is really slow. After all, IPv6 launched on June 6, 2012. We’ve had more than a decade to move to IPv6!

I am no help… I am just as guilty as anyone else. When I order a VPS, I ensure that I have a dedicated IPv4 IP address. Why? Legacy reasons! Well, more out of habit. I’m quite sure I could migrate to IPv6 by just changing a few things in my process.

Anyhow… This is a long intro!

What is this ‘ping’ thing? Well, ping is you sending a packet to an address and then waiting for the response. You ping a server and the server effectively sends a pong back! It’s ping pong! Ha! I crack me up. 

You send a ping and wait for an acknowledgment from the server when it sends a packet back to your computer. Ping doesn’t always work because you can decide to ignore them (perhaps a future article) and not send a response. Fortunately, the easy-to-remember domain names (remember, they respond on an IP address, they are resolved to an IP address) respond to pings. I use ‘google.com’ as a general rule.

If you check the man page, ping describes itself like this:

ping – send ICMP ECHO_REQUEST to network hosts

We’ll be using ‘localhost’ (your computer) for this article, for the record. I think that’s a better choice than having a bunch of my readers ping any specific website. It should be effective on every modern computer with a modern operating system.

Man, this is a long intro. I’m sure I’ve forgotten something…

Ping With IPv4 or IPv6:

By now you know the routine. You’ll be using a terminal for this exercise. If you don’t know how to open your terminal, try pressing CTRL + ALT + T and (in most cases) and your terminal should pop right up! It’s magic!

Believe it or not, this may also work for other operating systems. I have it on good authority that this works with Windows, where they’ll be using ‘cmd.exe’ as memory serves. From what I can tell, this is also true for MacOS users. It’s a fair assumption to say this also works with the operating systems in the BSD family. Huh… Imagine that?!?

Anyhow, you can try the following command:

That will resolve to an IP address, be it IPv4 or IPv6. You can ping a specific IP address easily enough. To ping an IP address, the syntax is:

The results of those commands will be either an IPv4 or IPv6 address. If you’re new and don’t know the difference, an IPv4 address uses periods. It’d look like 127.0.0.1. An IPv6 address uses colons. It’d look like 2607:f8b0:4006:817::200e. It’s easy to tell the difference.

Now, if you want to use IPv4, the command would be like this:

If you want to use IPv6, the command would be like this:

NOTE: This is likely to work in many instances but, due to the lack of participation, you might find that some sites don’t support IPv6. On the other hand, you might find some sites don’t support IPv4. If one doesn’t work, then you have the other as an option.

Closure:

Well, if you ever wanted to know how to ping with IPv4 or IPv6, you now know. Are there good reasons? Well, there’s still some legacy stuff out there and we’ve poorly adopted IPv6. For all intents and purposes (intensive porpoises) we have limitless IP addresses available with IPv6.

We will move in that direction, just like we’ve currently moved in that direction. Adoption will continue and adoption rates may speed up. After all, we’ve had more than a decade to adopt. The specification is well-supported and it’s almost certainly the future of networking. Or so I’d like to believe…

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Add A New Line With CURL

Today’s article isn’t going to be all that long and it’s definitely not going to be complicated, as we just discuss how to add a new line with curl. It’s just an annoyance factor and something I was reminded of today. Lacking a better idea, I decided I’d use this annoyance and recollection as a reason to write an article about how to add a new line with curl.

First, this obviously requires a terminal.

Second, this obviously requires curl. You almost certainly have curl installed, so you won’t have to install anything. 

If you’re curious, you’ll find that the curl man page defines the application as:

curl – transfer a URL

You’ll understand why I’d use that in a second, but you can imagine that it’s a pretty handy tool to have in your Linux toolbox. We’ve previously used curl in many articles. Here’s a sampling of those articles:

Let’s Have a Limited Look at Linux’s cURL Application
Weather In The Terminal? We can do that!
How To: Find Your IP Address Through Your Terminal

… and more!

So, in this case, I show ads on the site. To do this, Google relies on a file known as ‘ads.txt’ being in your web’s root folder (often called ‘public_html’). If the file is not there, there’s an ad inventory issue and Google won’t show ads.

Well, if you read the previous article you’d know that there was an outage. During this outage, it appeared that the site was still reachable – except it wasn’t. It was during this time that AdSense decided to check and see if the ‘ads.txt’ file is there. (This is nothing private. Everyone using AdSense has an ads.txt file.)

Because of this, I decided to verify that the ads.txt file existed and contained the appropriate information. To do this, I simply used the following command:

It gave me the answer I wanted, but I disliked the formatting of the output. But, it was enough for me to determine that the file existed and that I just had to wait for Google to confirm this.

The formatting was horrible. I’ll show you an image in the next section and you’ll see…

Add A New Line With curl:

So, when I saw the output from the above command (feel free to run it on your computer), it just ran the line into the next prompt. I had to dig through my ~/bash_history file because I couldn’t remember how to fix the formatting.

A picture is probably going to describe this best. In the picture, you’ll see the ugly formatting and you’ll see the solution.

adding a new line to the curl output
As you can see, the second command has a much nicer output.

So, to make sure you have a new line, you use the -w (write-out) flag and add the character for a new line in quotes – which is "\n". It’d look like this:

As you can see (and I hit the enter button between commands to start on a fresh new line) the output is much nicer. So, instead of curl starting a new line, a command entry line as it were, you’re starting with a nice fresh new line.

I messed with this way too long before I started digging into my bash history to find other curl commands used over time. Eventually, I found it, but I’d already verified that the file existed and that Google would notice the next time they checked.

Closure:

Well, it’s not the greatest of articles – but it’s useful if you want to know how to add a new line with curl. It’s a much tidier output this way. I just need to remember to do it without having to dig through my bash history each time I want to have a clear curl output.

Meh… I’m sure it’ll eventually be handy for someone…

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Geolocate A Website

Today’s article probably will be more about amusement than it is about education, as we learn to geolocate a website. This will not have a lot of uses for many of you, and the uses I can think of are a bit contrived. So, stand back and watch as we do some science!

Wait, no… No, there will be no science.

What I should have done is write this article ahead of time. Instead, it’s the 4th of July, and will probably be just about the 5th of July before I finish this. Let’s just all agree that I’ve been celebrating.

Anyhow, have you ever wanted to know where a website is located? Have you ever wanted to know where an IP address is located? Well, that’s what geolocation does and let me tell you that it is not excellent. No, it is not.

First, the tool we’ll be using is only going to give you the country. It doesn’t narrow it down very far.

Second, in the world of CDNs (Content Delivery Networks), a server may appear closer to you (or in this case the geolocation server) than it is. 

Relying on this data for anything important is just plain silly. 

But, you could log in to a remote server by name, get the local IP address, and then check the IP address to see what country the server is in. Yeah, see? I told you that any usefulness would be contrived.

Anyhow, you can geolocate by domain name or by IP address. With any luck, you’ll be able to tell which country the server is in. The previously mentioned caveats should make sure you know to not use these results for anything useful. 

Geolocate A Website:

You could almost certainly find an online tool that would do a much better job. Installing software for this is not necessary, but that’s exactly what we’re going to do. So, press CTRL + ALT + T and let’s get this party started.

First, we need to install a piece of software called Geoip. It’s available for all the major distros and describes itself as:

geoiplookup – look up country using IP Address or hostname

To install the software, you’ll enter one of the following commands into your terminal of choice:

RHEL, CentOS, Fedora, etc:

Arch, EndeavourOS, Manjaro, etc:

Debian, Ubuntu, Mint, etc:

When you’re done with that, it’s pretty easy to use. If you want to geolocate a website, the format follows:

And, if you want to geolocate an IP address, the syntax is similar:

An example output follows:

Which, you know, isn’t all that helpful. You can check the man page, but that’s also not all that helpful. To do that, it’s just this command:

The data isn’t entirely useless, for example, you can try this command:

Which, as you can see, appears to accurately geolocate the domain name to Canada, which is where I’d expect the server to be.

Closure:

So, yeah… If you want to geolocate a website then you can more or less do so. You’ll not get a whole lot of useful information and there are better tools for this online, but it can be done. You can indeed geolocate a domain name or an IP address all from the comfort of your terminal.

Just, you know, don’t use this information for anything too important. I use MaxMind for this sort of stuff online. It’s useful for getting meaningful statistics regarding the site’s traffic and is much more accurate, but still not accurate enough to pinpoint a house or anything. It can usually narrow things down to the nearest city, which is more than enough for my needs.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Change DNS Servers

Today’s article shouldn’t be all that difficult for even our newest users but is limited to those who want to change DNS servers to something other than the default. This is easy enough to do, but obscure enough to warrant an article of its own. 

First, let’s have some fun. I’m going to ask ChatGPT to tell you about DNS in just two paragraphs. So, let’s see what the AI has to say:

First, what is DNS?

DNS, or the Domain Name System, is a fundamental protocol used in computer networks to translate human-readable domain names into machine-readable IP addresses. It serves as a decentralized directory system that enables users to access websites, send emails, and perform various network activities using familiar domain names instead of numerical IP addresses. When a user enters a domain name in their web browser, the DNS resolver (typically provided by the Internet Service Provider or ISP) initiates a series of queries to locate the corresponding IP address. The resolver communicates with DNS servers, starting from the root servers, then the top-level domain servers, and finally the authoritative name servers associated with the requested domain. Through this hierarchical process, DNS ensures efficient and accurate resolution of domain names, facilitating seamless internet connectivity.

DNS operates through a distributed database system known as the DNS namespace. This namespace is organized hierarchically, with the root domain at the top, followed by top-level domains (TLDs) like .com, .org, or country-specific domains such as .us or .uk. Beneath the TLDs, there are second-level domains, and further subdivisions like subdomains. Each domain has authoritative name servers that store the IP addresses associated with the domain names they manage. DNS resolution occurs through recursive queries, where the resolver traverses the DNS hierarchy to find the authoritative name servers responsible for the domain. Once the IP address is obtained, the resolver caches it for future use, reducing the need for repetitive queries. DNS plays a crucial role in the functioning of the internet by providing a scalable and efficient method for translating domain names to IP addresses, enabling seamless communication and accessibility across the network.

Wow! That’s pretty accurate. I’d have just resorted to describing DNS as the telephone book of the internet. You look up the name you want to reach and DNS tells you the number. In this case, the number is the IP address.

All in all, I’d say ChatGPT did a pretty fine job.

Change DNS Servers:

There are a variety of reasons why someone would want to change DNS servers to something else. They may get updated more quickly, weed out junk domains, or even remove ads and things like that. Maybe you want to weed out inappropriate material because you have children. Perhaps you have some custom configurations needed to traverse your complex local network. There are all sorts of reasons why you might want to change DNS servers.

See, as alluded to above, it’s perfectly possible to run your own DNS server (see Pi-hole for one such example). You can also use DNS servers provided by various third parties. For example, CloudFlare and Google offer their own DNS servers that are free for you to use. There are other choices, but this isn’t an encyclopedia writ large, so I’m going to just include those two. You can use your favorite search engine to find more.

So, let’s say you don’t like using a DNS server provided by your ISP. Perhaps you do this because of privacy issues, though you can look into DNS over HTTPS if you’d like. Perhaps you just don’t find them updated quickly enough or you’ve found they contain errors. (They do sometimes have issues and have even been known to be exploited in the past.)

NOTE: We’ll be using ‘nano‘ for this exercise. We’ll also default to Google’s public DNS servers, but you can substitute with whatever you find available.

Well, the first step you’re going to take is opening your terminal. You can do that by just pressing CTRL + ALT + T. In most distros, that will open the default terminal emulator. If your distro doesn’t do so, start mucking about with the keybindings until it does!

The file we’ll be editing doesn’t actually exist on most distros. That’s not a problem, because we’ll be making that file with nano. With your terminal open, enter the following command:

That should be a perfectly blank file and you’ll want to enter the following (again, using Google’s public DNS servers) to change DNS servers:

Then, you’ll save the file with Nano. That’s pretty easy. To save this new resolv.conf file with nano, you just press CTRL + X, then Y, and then ENTER.

Next, you’ll need to reboot. I know this will pain some of you, but I’ve yet to have a sure way to effect these changes other than rebooting. So, you’ve gotta do that. Try this command:

Now that you’ve managed to change DNS servers, you should be able to browse around much as you normally would. Remember, the people in charge of the DNS servers are the ones that decide where you go when you enter an address into the address bar and smash that enter button.

Be sure to use a company you trust to provide those services and be sure to verify your internet is still working properly. If it’s not working, you can remove the file and reboot or you can edit it again and try rebooting again. It shouldn’t be a problem in reality, this isn’t anything all that complicated.

Closure:

So, there you have it. It’s yet another article. This time around we discussed how to change DNS servers – along with some reasons as to why you might want to. If you have a spare bit of hardware kicking about, you can make your own DNS server and point to that with the internal addresses you’d be using. It’s nothing too painful and I think even beginning Linux users can follow along easily enough.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

A Fun Way To Check If Your Network Devices Are Connected

Today is going to be a fun article, mostly good for lazy people, where we discuss a way to check if your network devices are connected. There are far easier ways to do this, assuming you’re local to the device. If you’re not local to the device, the fact that you’re connecting to it likely means that the network is at least somehow connected!

But, in the spirit of being lazy, let’s head into the world of sheer, unadulterated laziness. I mean, if you want to know if your wireless is connected there’s an icon. Of course, you can see if your ethernet is connected. To check that ethernet connection all you probably have to do is look at the back of the computer and maybe wiggle the cable a little bit.

This, of course, presumes that said network adapters are in working condition. If they’re broken, this tool might give you a bit of debugging information. But, still, this is a command that calls itself a “beat connector”. It’s mostly used to check to see if your network devices are connected – as in physically connected to your computer.

The tool we’ll be using will be ifplugstatus and it defines itself as this:

ifplugstatus – A link beat detection tool

At least as far as I use it and the man page indicates, it checks to see if your network devices are connected. Seeing as that’s what the title suggests, it means we’re probably off to a good start!

Check If Your Network Devices Are Connected:

First things first… You’ll almost certainly find that ifplugstatus is not installed by default. You’ll need to install ifplugstatus if you want to use it. To do that, you’ll need an open terminal – which you’ll need for the rest of the article. To open your terminal, press CTRL + ALT + T and your default terminal should open.

Now, I’ve only ever used this command with Lubuntu and similar. Because of this, I don’t know if it’s the same on other distros. (Feel free to leave a comment.) But, at least in Lubuntu, not only is ifplugstatus not installed by default, that’s not the name of the package you need to install. No, that’s a different name and to install ifplugstatus you will want to run the following command:

You’ll need to adjust that command to match the distro you’re using.

Anyhow, with ifplugstatus installed, you can check if your network devices are connected with just the following command:

But wait! There’s more! You can get a lot more information about your network devices by adding the -v (verbose) flag to the command. That flag automatically assumes the -a (all) flag, so it’s just:

There you have it… Instead of just looking in the status bar section to see if wireless is connected, or even looking around the back to see if the cable is connected, you can just check all that right there in the terminal – without having to move much more than your hands! You’re welcome!

Closure:

Heh… There you have it! You have another article. If you ever want to check for a beat, that is to check if your network devices are connected, you now know how to do so. You can even SSH into another device and check to see which of its network devices are connected (beyond the obvious one you’re connecting with). You don’t even have to leave your seat.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.