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. 学习SVG系列(4):SVG滤镜效果

    注意:Internet Explorer和Safari不支持SVG滤镜 <defs>.<filter> 所有互联网的SVG滤镜定义在<defs>元素中,<fi ...

  2. PHP时区配置

    在PHP安装目录中找到 php.ini-development 复制创建新的副本 找到 :date.timezone = 修改为 date.timezone = PRC 并保存为php.ini PRC ...

  3. github上下载的文件如何在本地运行

    最近想学习自己写插件,所以先下载大神写的插件膜拜下,下载下来以后,直接双击运行报错,大神怎么会犯这么低级的错误咧!所以在网上查资料,找到了解决方法. (1)上传到github上面的插件都很规范,文件根 ...

  4. IOS设备 UIDevice 获取操作系统 版本 电量 临近手机触发消息检测 (真机亲测可用)

    - (void)viewDidLoad { [super viewDidLoad]; // 操作系统 NSString * osName =[[UIDevice currentDevice]syste ...

  5. 加密web.config

    当我们要进行数据库的连接时,就会根据<%$ connectionsStrings:MyConnectionStringName %>这个表达式在Web.config文件中找到和MyConn ...

  6. 《深入浅出Node.js》第5章 内存控制(未完)

    @by Ruth92(转载请注明出处) 第5章 内存控制 基于无阻塞.事件驱动建立的 Node 服务,具有内存消耗低的优点,非常适合处理海量的网络请求. 内存控制正是在海量请求和长时间运行的前提下进行 ...

  7. 手把手教你配置UltraEdit对Oracle的PLSQL着色

    http://hi.baidu.com/kingbridge/blog/item/94e225ad5fad4b194b36d60d.html   UltraEdit-32 12.1版本配置默认文件显示 ...

  8. 反射【类Class、成员变量Field、方法Method】

    Class<?> c = Class.forName("main.Main$MyClass"); //要包名+类名 Object obj = c.newInstance ...

  9. [NOIP2011] 聪明的质检员(二分答案)

    题目描述 小T 是一名质量监督员,最近负责检验一批矿产的质量.这批矿产共有 n 个矿石,从 1到n 逐一编号,每个矿石都有自己的重量 wi 以及价值vi .检验矿产的流程是: 1 .给定m 个区间[L ...

  10. 实现DevExpress GridControl 只有鼠标双击后才进行修改数据

    1. 实现DevExpress GridControl 只有鼠标双击后才进行修改数据:修改GridView.OptionsBehavior.EditorShowMode属性为Click 2. 实现De ...