Setting static IP address on Ubuntu Server 16.04

Recently, I have been getting more and more interested in Linux servers and operating systems. Many people don’t realize that Linux is the most prevalent operating system in the world. It runs on all of our android devices, web servers, firewalls, backup devices, cars, and many more. I would really like to get a Linux certification, but for right now I am working on my Security+ and some others that I need to do my job. I am currently setting up a linux server and it is usually a good idea to set up a server with a static IP address. This is just one of those things that I don’t do that often and I would rather go to my own knowledge base than another knowledge base. I will be working at the command line because my server does not have a desktop environment installed. I am also using VirtualBox to configure my server and then I will export it to a vmware environment. Also, one thing that any sysadmin should do before changing a config file in any server is make sure

The first thing I like to do is find my IP address with the ifconfig command. This is the output:

The IP address I am looking for is the enp0s3. I will set my IP address statically to this. The next thing I have to do is navigate to the file that holds the information for the interfaces. The file is located at /etc/network/interfaces. The text editor I like to use is nano. I know a lot of people like vim and that is ok. If you feel more comfortable using that then that is ok.

The command will look like this: sudo nano /etc/network/interfaces

The output should look like this:

Find “# The primary network interface” and here is what you will change.
Change dhcp to static. Add address, netmask, gateway, and dns-nameservers so that it looks like this:

Save the file and exit. Now flush the ip address to make sure it assigns the IP address back and restart the networking service. You can flush the IP address with this command:
sudo ip addr flush enp0s3
(You will not get any output from this.)
Restart the networking service with this command:
sudo systemctl restart networking.service
(You will not get any output from this.)
After you run these commands try pinging an ip address or website. If you get 0% packet loss then you know it worked. If you don’t then more troubleshooting will be needed. I hope you found this helpful. If you have further questions please send me an email in the contact me and give me a +1! 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close