Temporarily Set A Static IP Address

Today we’ll have a fairly simple article that may not generate much interest as we’re just learning how to temporarily set a static IP address. This isn’t all that difficult, as I’ll just show you the syntax, but it’s something you might find worth knowing. So, if you’re interested in learning how to temporarily set a static IP address, read on!

What is an IP address?

If you have to ask that question, this article isn’t one that you need to try. You can, it’s just usually something reserved for specific circumstances.

Every networked computer is assigned a numerical IP address. You may have more than one address, including a public and a private IP address. It’s possible to have an IP address on multiple network interfaces, but every connected computer has an IP address. That’s what we use for the web – you just don’t see it as we use domain names that get resolved to IP addresses.

Some links you should read:

How To: Find Your IP Address Through Your Terminal
Find Your Network Interface Name
A Couple More Ways To Find Your Network Interfaces

Those articles aren’t all on the same subject, but they’re articles where I discuss things like IP addresses and DNS. If you’re new to this, you should read the first link, about how to find your IP address. 

The IP address we’re concerned with is our private IP address. This is different than our public IP address and is used on your local network. It’s the address your router sends data, for example. If you remotely control devices on your network, that IP address is what goes on behind the scenes as it denotes the device.

Each private IP address will almost certainly resolve to just one device. This is not true everywhere. One IP address can have many websites and some ISPs are doing IP address subnets for public IP addresses because they’ve run out of IPv4 IP addresses. You needn’t concern yourself with that and that’s just for some random information.

So, the IP address we’ll be setting as a static IP address will be your internal, that is private, IP address. I sometimes do this when I don’t want to have to hunt around for an IP address and device.local isn’t working.

This will only be a temporary change. When you reboot your computer, you may have an entirely different IP address. I don’t want to add complexity, but some routers may already assign a device the same IP address every time it sees it. While this isn’t a static IP address per se, it’s effectively the same.

We’ll be setting that private IP address locally, establishing it on the computer itself. Any modern router should handle the change just fine. However, this may prove problematic for those who have equipment that strays from normal behavior. If that’s the case for you, either reboot or just change your IP address back to what it was originally and everything should be good. However, I can’t see this being a problem, because your original IP address will still work just fine.

Got all that figured out? Well, good! Let’s jump into the article!

Temporarily Set A Static IP Address:

Yes, you’re going to need an open terminal for this. There might be a way to do this with a GUI, but I’ve never tried it. Route around in your network manager and there might be a way. Specifically, check for DHCP and see if there’s a way to change that to a manually configured IP address. It might be the ticket. I’m seeing something similar to that in my network manager, but I haven’t tested it.

Anyhow, as you’re going to need an open terminal, you can probably just press CTRL + ALT + T to open your default terminal. If that doesn’t work, just open it from the application menu. You’ll probably find a terminal application listed under your administration (or system) tools. That’s a good spot to start looking.

With your terminal now open, we need to find the name of your network interface. I shared a link in the opening section, but the command is just this (assuming you’re using a modern distro):

Your network interface names will look something like enp2s0 (for an ethernet/wired connection) or maybe something like wlxe4beed0e5f5c for a wireless network interface. You can assume ‘en’ is ethernet and ‘we’ is wireless. That seems to be fairly consistent. 

Now, while you’re there, you need to determine your IP address, specifically your private IP address. This may look something like this:

That’s the number you’re going to change.

NOTE: Unless otherwise noted, you want to stick to Class C private network addresses. These are addresses reserved for your private networking and are 192.168.0.0 to 192.168.255.255.

So, let’s say your private IP address is indeed 192.168.1.4 and you want to change it to 192.168.1.42 (because 42 is indeed the answer). You can do that. The syntax needed to temporarily set a static IP address is as follows:

So, it’d look like this:

Next, you verify that it worked:

What this does is it adds a static IP address. Your original IP address will still work, but you’ll have designated and set a static IP address that will also work.

You can add all sorts of static IP addresses by this means. If you run the ip addr command again, you’ll see that the static IP address has been added under the fixroute <network_interface_name> heading.

For example, see this image:

setting a static ip address
Any and all of those private IP addresses will now work and remain static.

You can just reset it to the same original IP address but you shouldn’t need to. This shouldn’t break anything because the original IP address remains the same and remains usable. You can connect to that computer with any one of those private IP addresses, each of them a static IP address.

It’s possible to make this change a permanent thing, which might make an interesting future article. I don’t think anyone will find it complicated. These things are easier to do than they are to explain. I spent more time with the verbiage than anything else. It’s hard to include all that you need to know because I don’t know what you know. 

Closure:

Well, there’s another article. If you’ve ever wondered how to set a static IP address, this is the answer. It’s not complicated. Anyone should be able to figure it out, using the syntax above. I hope that I’ve made it clear. Sometimes it’s not all that easy to explain stuff in plain English without going too deep.

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: Find A Website’s IP Address

Today’s article should be interesting, as we learn how to find a website’s IP address. There’s more than one way to do this sort of thing, so I’ll just be showing you the one way to do so. I want to keep it relatively short and simple. So, to find out how to find a website’s IP address, read on!

I have a reason to keep this one short and simple. I’m in the midst of a blizzard and am likely to lose my connection at some point this evening. That’s okay, I love the cold and snow. As for me and my house, I’ve got solar and wind. I won’t want for anything. I’ve been out playing in the snow already. I’ll go back out shortly.

So, let’s say you want to know the IP address of your favorite website. That’s easy enough to learn. Though it may surprise you that your favorite website might have multiple IP addresses. That’d often be because many websites have multiple nameservers pointing at them for a bit of redundancy.

We’ll be using the ‘dig’ tool. This is likely installed by default. You shouldn’t need to install anything. The dig command defines itself as:

dig – DNS lookup utility

That’s what we’ll be using to find a website’s IP address, as it’s a fine tool for doing so. With that said, let’s just jump into the article…

Find A Website’s IP Address:

If you’re a regular reader, you know that it’s probably time to open a terminal. Like many articles, this one requires an open terminal, as that’s where you use the dig command. Just press CTRL + ALT + T and your default terminal should open.

With your terminal open, we’ll use Linux Tips as our example:

The output of which should look like this:

using dig to find a website's ip address
You’d be looking for the answer section, as indicated in the graphic. Pretty easy, huh?

As you can see, the answer section is what you’re looking for. The IP addresses are on the right. As you can see, this site has two IP addresses – both of which belong to my CDN (if you’re curious).

You can save some time and space… Well, some space. I suppose it may take you a second or so longer to type out the extra characters. But, give it a try with the +short flag (placed in a weird spot).

The output from that command is a bit easier and more concise:

using +short is a neater output to find a website's ip address.
That’s a bit easier and contains just the information you’re looking for. You can just use that.

You can use either or both, depending on what you’re after. I suppose it’s technically a bit longer when you type in the last command, but your output is just the information you’ve been looking for.

By the way, dig +short linux-tips.us will work, I just learned it the other way, so that’s how it is situated in my notes. If you’re feeling weird about placing the flag at the end of the command, just place it where flags normally go. Also, don’t forget to check the man page with man dig for more information about the dig command.

Closure:

And there you have it, you have another article! This time we’ve covered how to find a website’s IP address. If the site has a dedicated IP address, you can use that IP address to connect to the site, as opposed to using the domain name. So, there’s that…

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: Find Your IP Address Through Your Terminal

The answer to the question, “What is my IP address?” can have different answers. In practice, you likely have more than one IP address. This article will explain how and will tell you how to use your terminal to find your IP address(es).

What is an IP address?

An IP address is a numerical designation given to computers on a network. This number is used to identify the computer. You can also identify a computer by their hostname, but the hostname is resolving to an IP address. Computers that are connected to a network will have an IP address.

There are two types of IP addresses to be curious about these days. There’s IPv4 and IPv6. IPv4 predates IPv6 and is still in use, but has run out of numbers. IPv6 solves that by enabling a whole lot more combinations. IPv6 has a potential of 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses – which is a whole lot of ’em, especially when compared to IPv4’s paltry ~4.3 billion addresses.

IPv4 addresses have technically already been exhausted, and have been since early 2011. The addresses still exist, but they’re all assigned to various entities. The IPv6 roll-out has been slow. Odds are good that you’re using IPv4 right now, in fact I know you are – as this site has an IPv4 address. Still, your router is likely handing out IPv4 addresses and your ISP is likely still using IPv4 addresses.

Additionally, in most cases, you would be concerned with two IP addresses. You’re likely connected to a router/modem that’s connected to the internet. As such, you will have a private IP address and you’ll have a public IP address. The first is (usually) assigned to your computer by your router and the second is assigned to your router by your ISP. This article will explain a little about each and how to find both of them.

Find Your Private IP Address:

Your private IP address will be in a reserved section of the IP address space. It will probably be handed down by DHCP (Dynamic Host Configuration Protocol), but many routers will both let you pick your IP address (from the reserved space) or will just assign the same IP address to the same device based on the MAC address (Media Access Control). 

The reasons you’d want to know it are your own, but it’s handy if you want to connect to a specific computer. As I know my laptop is 192.168.1.5, I can just SSH into it using that address. I know my media server is a different address, and I can connect to it with the IP address as well.

There are a number of ways to find your private IP address. I’ll share two of them that are quick and easy. For this, you’re going to want to open your terminal, which you can do by pressing CTRL + ALT + T and it should open right up.

First try:

You can also try:

In both cases, you look for ‘inet’ AND your device. You’re not looking for ‘loopback’, as that will likely list your IP address as 127.0.0.1 – which isn’t the address you’re after for reasons beyond the scope of this article.

You’re looking for your device, maybe named ‘eth0’ or ‘wlo1’ or similar, and then you’re looking for ‘inet’. Your IP address is the next four sets of digits (or alphanumeric combinations in the case of IPv6). For example:

example IP address
I’m not so sure the underlining matters.

One or both of those methods should work for you with any major distribution. There are surely many other ways to find your IP address, so feel free to leave a comment indicating how you do it.

Find Your Public IP Address:

The next kind of address is your public IP address. This is the IP address your ISP assigns you. If you wanted to connect to your computer over the world-wide-web, you’d be able to do so (with obvious caveats and proper configuration) with your public IP address.

It’s also the address I see (unless you’re using a VPN) in my server logs when you visit my site. That’s perfectly normal – as my site needs to know where to send the return packets. If my site didn’t know an address to send data to, it simply wouldn’t work.

You can think of this as the IP address assigned to the public side of your router, and your router then passes that information along via the private IP address that originated the request. This lets you have multiple devices using the same public IP address. (Read about NAT here.)

My understanding is that some ISPs are NATing public IPv4 addresses so that multiple routers can actually have the same IP address (not necessarily a good thing). However, that too goes beyond the scope of this article and isn’t want this site is actually about.

Anyhow, there are numerous public servers out there that you can ‘cURL‘ and those will give you your public IP address right there in the terminal. Just like above, you can open your terminal by using your keyboard and pressing CTRL + ALT + T. Once open, you can try:

Or you can try:

It should look a little something like this:

my public IP address
Yes, that’s my public IP address. No, I don’t care.

There are numerous other sites that’ll spit out the same info. The top-most example was recently handed over to Cloudflare, just so folks are aware.

Closure:

And, there you have it. You now know how to find your public IP address and how to find your private IP address from within the terminal. There are also many dozens of websites that will tell you your public IP address, but we might as well stick to the terminal for this one. Why not? You can do a lot in the terminal.

Once again, thanks for reading. Your comments and feedback help make the site better. As always, you can donate, write an article, sign up for the newsletter below, register, and vote to let me know which articles you prefer. If you sign up for the newsletter, you’ll get notifications when new articles are published. No spam, I promise!

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.