Change Ubuntu Server from DHCP to a Static IP Address

If the Ubuntu Server installer has set your server to use DHCP, you will want to change it to a static IP address so that people can actually use it.

Changing this setting without a GUI will require some text editing, but that’s classic linux, right?

Let’s open up the /etc/network/interfaces file. I’m going to use vi, but you can choose a different editor

sudo vi /etc/network/interfaces

For the primary interface, which is usually eth0, you will see these lines:

auto eth0

iface eth0 inet dhcp

As you can see, it’s using DHCP right now. We are going to change
dhcp to static, and then there are a number of options that should be
added below it. Obviously you’d customize this to your network.

auto eth0

iface eth0 inet static

address 192.168.1.100

netmask 255.255.255.0

network 192.168.1.0

broadcast 192.168.1.255

gateway 192.168.1.1

dns-nameservers 192.168.1.1

Now we’ll need to add in the DNS settings by editing the resolv.conf file:

sudo vi /etc/resolv.conf

On the line ‘name server xxx.xxx.xxx.xxx’ replace the x with the IP
of your name server. (You can do ifconfig /all to find out what they
are)

You need to also remove the dhcp client for this to stick (thanks to
Peter for noticing). You might need to remove dhcp-client3 instead.

sudo apt-get remove dhcp-client

Now we’ll just need to restart the networking components:

sudo /etc/init.d/networking restart

Ping www.google.com. If you get a response, name resolution is working(unless of course if google is in your hosts file).

Really pretty simple.

Updated Thanks to Nickname007 in the comments for noting that I forgot the DNS entries in the guide.

http://blog.163.com/howl_prowler/blog/static/26619715201011225642570/

Ubuntu setup Static IP Address的更多相关文章

  1. 给ubuntu设置静态ip —— How to set static IP Address in Ubuntu Server 16.04

    原文: http://www.configserverfirewall.com/ubuntu-linux/ubuntu-set-static-ip-address/ ----------------- ...

  2. Config Static IP Address manually in Ubuntu

    The process of the configuration of static IP address in Ubuntu is as follows: ``` $ sudo vim /etc/n ...

  3. How to configure a static IP address on CentOS 7(CentOS7静态IP地址设置)

    Question: On CentOS 7, I want to switch from DHCP to static IP address configuration with one of my ...

  4. Setting up a static IP address in Ubuntu

    sudo gedit /etc/network/interfaces Change the line iface eth0 inet dhcp to iface eth0 inet static an ...

  5. ubuntu使用git的时:Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.

    1:问题现象: hlp@hlp:~/code/github_code/catch_imooc1$ git push origin master Warning: Permanently added t ...

  6. ubuntu 修改静态IP和DNS

    1.修改配置文件/etc/network/interfacesroot@ubuntu:~# sudo vi /etc/network/interfaces 添加以下内容:auto eth0       ...

  7. ubuntu无线上网静态ip配置以及配置静态IP 之后无法正常上网的解决方案

    一. 配置无线网络的静态IP 编辑/etc/network/interfaces文件如下: auto lo wlan0 iface lo inet loopback iface wlan0 inet ...

  8. 给 Virtualbox 中 Ubuntu 系统设置静态 IP ,让 DNS 配置信息不会在重启后被清除

    虚拟机网络选择 桥接网卡 模式. 主要涉及两个步骤: 1. 修改 /etc/network/interfaces 文件: 2. 修改 dns : 第一步,修改 interfaces 文件: sudo ...

  9. Linux - ubuntu 设置固定ip和设置dns

    ubuntu 设置固定ip和设置dns 1.ifconfig 查看网卡名称 root@jiqing-virtual-machine:~# ifconfig ens32 Link encap:以太网 硬 ...

随机推荐

  1. Session Tracking Approaches

    cookies url rewriting hidden field see also: http://www.informit.com/articles/article.aspx?p=29817&a ...

  2. ubuntu 下更新PHP版本 ZT

    sudo add-apt-repository ppa:ondrej/php5 如果报错 add-apt-repository: command not found add-apt-repositor ...

  3. BZOJ 2743 树状数组

    不能用分块. #include <bits/stdc++.h> using namespace std; ; struct Info{int l,r,Id;}Q[Maxn]; int a[ ...

  4. django文件批量上传-简写版

    模板中创建表单 <form method='post' enctype='multipart/form-data' action='/upload/'> <input type='f ...

  5. vue学习笔记

    来公司以后就一直在用vue框架,不管是业务代码,还是做vue组件.关于vue有一些点是文档中没有提及的,记录一下以便以后查询- 一.Vue的特点 新一代 Vue.js 框架非常关注如何用极少的外部特性 ...

  6. 对git的理解及常用指令

    以前总听说git[分布式版本控制系统]自己愣是搞不懂它到底要干哈-什么叫版本控制系统根本理解不了.现在工作需要必须要用到,结果好像就突然懂了git是干什么滴. 所以!原理这个东西的理解是要建立在大量的 ...

  7. Ruby on Rails搭建环境出现的问题及解决方案

    问题一:在win7系统64位环境下执行cmd命令:rails new testapp 之后,回报如下图错误:Gem:installer::ExtensionBuildError: ERROR:Fail ...

  8. C# 属性控件2

    PropertyGrid,.net框架下的一个控件,这是一个软件升级的项目,原来的软件用的是C++,控件用的还是第三方,这次升级到visual studio .net4.0版本,原以为.net的东西用 ...

  9. 10——operator=返回reference to *this

    注意operator=返回一个引用,便于连锁赋值

  10. 项目用到的icarouls类和UIEffectDesignerView类,菜单技巧,构思(金方圆)

    // //  MenuHomeViewController.m //  HFYS // //  Created by Showsoft_002 on 13-8-14. //  Copyright (c ...