• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

How to configure static ip address through command line in Ubuntu

October 27, 2013 by Sharad Chhetri Leave a Comment

In this tutorial we will learn simple steps to configure the static ip address in Ubuntu by using command line.
It is always be a good practice to work on Linux or Unix system using command line.As a system admin we always prefer to work by using command line.

Follow the given below steps to configure static ip address through command line in Ubuntu

Step 1: Login into your system and become a superuser or root

sudo su - 

or 

su -

Step 2: Now edit the file /etc/network/interfaces. Before this first of all you have to check what is the ethernet device name which is available in system and on which we will configure the static ip address.

First of all run the below command and find the ethernet device name,here for eg, we are using eth0


ifconfig -a 

eth0

Now edit the /etc/network/interfaces file using your favorite file editor and paste the given below content as per your information. (Here I am using the vi editor)

Replace the given value

aa.bb.cc.dd replace with the ip address assigned for the system
yyy.yyy.yyy.yyy replace with Netmask of IP Address
pp.qq.rr.ss replace with Gateway IP Address

vi /etc/network/interfaces

auto eth0
iface eth0 inet static
address aa.bb.cc.dd
netmask yyy.yyy.yyy.yyy
gateway pp.qq.rr.ss

For eg.

auto eth0
iface eth0 inet static
address 192.168.122.101
netmask 255.255.255.0
gateway  192.168.122.101


Step 3:
Now restart the network service

/etc/init.d/networking restart

Step 4: To change the Nameserver settings. Edit the resolv.conf file. In below example I am using Google Nameserver IP Address. You can replace the nameserver information as per your network requirement.

vi /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Configure Nginx for Jekyll / Octopress / pelican based static website
  2. Configure ethernet to get IP address from DHCP in Ubuntu and Debian
  3. How to upgrade ubuntu 12.10 to 13.04 through command line
  4. How to empty Trash through command line in Ubuntu
  5. How to upgrade Ubuntu 13.04 to 13.10 by command line
  6. Install XFCE Desktop in Ubuntu through command line
  7. How to install and configure nagios nrpe client in Ubuntu with apt-get command
  8. How to configure multiple mysql instance in Ubuntu
  9. linux release renew dhcp assigned ip address
  10. Access Control by host and ip address in Apache 2.4

Filed Under: Linux Tagged With: static IP, ubuntu

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

Forward all incoming emails to other SMTP server or gateway

Replace keyword with its filename without extension : bash script

Error installing rails

set and unset line number in file with vi editor

configure: error: C++ compiler cannot create executables

How to convert float to integer number

How to download package using apt-get command in ubuntu

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy