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. ASP.NET 学习记录之一

    (放着期末考试不复习,我每天废寝忘食地阅读从图书馆借来的ASP.NET相关专业书籍,到现在快一个星期,终于掌握了点东西,但是一拿到真刀真枪就做不出来什么了:老师把实验室打开,我就在这码码代码咯) As ...

  2. iOS 线性滚动

    在这里,给大家带来简单的滚动实现,首先看一下实现效果. 通过观察不难发现,有很多地方并不是那么容易想出来的,对于篇随笔,感兴趣可以查查相关资料,我就不尽行过多说明,(主要是开考文字,不好说明

  3. jquery实现自动补全邮箱地址

    开始做的邮箱补全代码 //检查email邮箱 function isEmail(str) { if (str.indexOf("@") > 0) { return true; ...

  4. linux精确查找命令

    1. find命令 命令 功能:搜寻文件与目录 功能: 语法: 语法:find 目录名 选项 常用选项有: 常用选项有: -name filename按名字查找 按名字查找 -type x 查找类型为 ...

  5. 使用SqlLocalDB命令行管理LocalDB

    SqlLocalDB.exe start v11.0 SqlLocalDB.exe info v11.0 SQL Server Management Stdio添加管道连接实例 默认实例名(local ...

  6. ORA-00942:table or view does not exist

    好好的表都建成功了,在PL/SQL中编辑数据时给我来这个提示,起的我没办法了.查到如下: oracle建表时有一个严重的问题,在此写出来,提醒大家注意: 先简单写一下错误内容,如各位已经发现过此问题并 ...

  7. ionic 打包签名

    IONIC用一下命令打包会自动签名并且打包 ionic build android 自己签名并且打包方法: 1>在你项目app\platforms\android目录下新建文件:debug-si ...

  8. Azure 媒体服务可将优质内容传输至 Apple TV

    作为内容提供商,如果想要将优质内容传输到Apple TV,需要使用Apple FairPlay Streaming (FPS)技术. 但是这个技术的构建比较繁琐,基于此,Azure提供了FairPla ...

  9. Servlet3.0 jsp跳转到Servlet 出现404错误的路径设置方法

    最近又遇到了这种问题,百度了好久,发现有人说要在action的路径里面写Servlet文件的绝对路径,比如说,单独打开servlet的地址为http://localhost:8080/TomcatTe ...

  10. MySQL初探

    慕课网http://www.imooc.com/learn/122 课程学习笔记     修改MySQL提示符        shell>mysql --prompt 提示符        my ...