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

-------------------------------------------------------------------------------------------------

How to set static IP Address in Ubuntu Server 16.04

It is really important to know how to configure static IP Address on Ubuntu Server, Because it is almost impossible to run a server without a static IP Address.

During the installation, Ubuntu Server by default configured to use dynamic IP Address. In this Tutorial we are going to learn how to set static IP Address in Ubuntu Server 16.04.

Following are the steps we are going to follow

  • Check Available network interfaces on Ubuntu Server 16.04
  • Add static IP Configuration to the network configuration file.
  • Restart Ubuntu Networking Service.

Check Available Network Interfaces on Ubuntu Server

First of all you need to get the list of available network interfaces on your Ubuntu Server 16.04. We can use ip link show command to find available network interfaces on Ubuntu Linux.

ip link show

You should get the similar output as below screenshot shows.

ip add command list Network Interfaces

As above image shows, Our Ubuntu Server has Ethernet interfaces called enp0s3. Next we'll set static IP address to the enp0s3 interface.

Set static IP Address to the network interface

For this example I am going configure enp0s3 Ethernet interfaces with following ip configuration

IP Address = 192.168.1.10

Network mask = 255.255.255.0

Default gateway = 192.168.1.1

DNS Server = 8.8.8.8 and 8.8.4.4

On Ubuntu server, in order to set static IP address we need to add IP configuration to the /etc/network/interfaces file. So open the /etc/network/interfaces file using a command line text editor (You can use vim or nano on Ubuntu Server).

vim /etc/network/interfaces

Then set static IP address as follows.

First line of configuration should be the word "auto" followed by the interface name (This brought up the network interface automatically when system boot or when networking restart).

auto enp0s3

The next line should specify whether to use static IP address or dhcp ip on the enp0s3 network interface. In our case it should be static.

auto enp0s3

iface enp0s3 inet static

Then add the static IP configuration as follows.

auto enp0s3

iface enp0s3 inet static

address 192.168.1.10

netmask 255.255.255.0

gateway 192.168.1.1

dns-nameservers 8.8.8.8 8.8.4.4

Restart Networking Service

After setting up IP Configuration, we need to restart Ubuntu networking service.

sudo ip addr flush enp0s3 && sudo systemctl restart networking.service

Verify the static IP configuration.

After restarting network, use ip add command to make sure that static ip address has been assigned to the network interface.

ip add

Then send ICMP request to a remote host to check the connectivity.

ping -c 4 google.com

Configure Multiple Network Interfaces

Same Way you can configure multiple network interface on ubuntu server using /etc/network/interfaces file.

Example

In the following example, I have set static IP Address on two network interfaces (enp0s3 and enp0s8).

auto enp0s3

iface enp0s3 inet static

address 192.168.1.10

netmask 255.255.255.0

gateway 192.168.1.1

dns-nameservers 8.8.8.8 8.8.4.4

auto enp0s8

iface enp0s8 inet static

address 192.168.0.100

netmask 255.255.255.0

*** Most important thing when configuring multiple interface is you cannot set multiple default gateways. Only one interface should configure with the default gateway. For other interfaces you should add default gateway using static routes.

Summary : Set Static IP Ubuntu Server 16.04

In this tutorial we learned how to set static ip address in Ubuntu server 16.04.

  • Using ip link show command we identified the available network interface in our ubuntu server 16.04.

给ubuntu设置静态ip —— How to set static IP Address in Ubuntu Server 16.04的更多相关文章

  1. Ubuntu Server 16.04修改IP、DNS、hosts

    本文记录下Ubuntu Server 16.04修改IP.DNS.hosts的方法 -------- 1. Ubuntu Server 16.04修改IP sudo vi /etc/network/i ...

  2. Ubuntu Server 16.04 安装MySQL并设置远程访问

    Ubuntu Server 16.04 安装MySQL 1. 使用root账号 sudo apt-get install mysql-serversudo apt-get install mysql- ...

  3. 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(三):设置上传文件夹权限(这里测试用完全共享)

    基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django 基于Ubuntu Server 16.04 LTS版本安装和部署Djan ...

  4. [原创]在HP DL380 G7服务器上部署基于Ubuntu Server 16.04 和 VirtualBox的云平台

    对于一线开发人员来说,一提到虚拟机平台,往往会让人联想到在价格昂贵的服务器上部署VMware vSphere之类软件来实现. 笔者作为一个资深码农,也是一直梦寐着在自己家中打造一个真正的家庭私有云,秒 ...

  5. Ubuntu Server 16.04.1系统安装

    一.Ubuntu Server 16.04.1系统安装 Ubuntu分为桌面版(desktop)和服务器版(Server),下面为大家介绍服务器版本Ubuntu Server 16.04.1的详细安装 ...

  6. 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(五):测试项目

    基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django 基于Ubuntu Server 16.04 LTS版本安装和部署Djan ...

  7. 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(四):安装MySQL数据库

    基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django 基于Ubuntu Server 16.04 LTS版本安装和部署Djan ...

  8. 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(二):Apache安装和配置

    基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django 基于Ubuntu Server 16.04 LTS版本安装和部署Djan ...

  9. 从零到一,利用kubeadm在ubuntu server 16.04 64位系统离线安装kubernetes v1.10.0

    说明 初步接触kubernets,记录学习过程 本教程目的利用kubeadm在ubuntu server 16.04 64位系统离线安装kubernets v1.10.0 环境信息 节点IP地址 角色 ...

随机推荐

  1. 模仿jq里的选择器和color样式

    (function(){ HTMLElement.prototype.css = function () { var option; if (arguments.length > 0) { op ...

  2. 【剑指offer】面试题 55. 二叉树的深度

    面试题 55. 二叉树的深度 题目一:二叉树的深度 题目描述:输入一棵二叉树,求该树的深度.从根结点到叶结点依次经过的结点(含根.叶结点)形成树的一条路径,最长路径的长度为树的深度. Java 实现 ...

  3. 基于kbengine 0.4.20 解读

    [以下文章转自kbe论坛] MMOG服务端是一种高品质的工程项目,品读开源的kbe是一种乐趣.本文档我带童鞋们一起领略一下.囿于我知识面和经验方面所限,文中所述之处难免有错误存在,还请读童鞋们睁大慧眼 ...

  4. 堆管理之malloc和free分析

    在win7 64环境下分析 1.malloc代码 int main(){ void *p = malloc(0xa8); memset(p, 'a', 0xa8); free(p); return 0 ...

  5. 连接LilyPad之Windows平台的驱动

    连接LilyPad之Windows平台的驱动 LilyPad和其他的Arduino控制板的不同之处是它是为电子织物和可穿戴设计的.那么,它的大小就必须要紧凑.所以,它并没有板载其他大多数板子都具有的U ...

  6. 对Webservice的理解

    eb   Service使用的是   SOAP   (Simple   Object   Access   Protocol)协议 soap协议只是用来封装消息用的.封装后的消息你可以通过各种已有的协 ...

  7. [BZOJ4836]二元运算(分治FFT)

    4836: [Lydsy1704月赛]二元运算 Time Limit: 8 Sec  Memory Limit: 128 MBSubmit: 578  Solved: 202[Submit][Stat ...

  8. bzoj 3373: [Usaco2004 Mar]Lying Livestock 说谎的牲畜

    3373: [Usaco2004 Mar]Lying Livestock 说谎的牲畜 Description 兽群中总是有一些麻烦制造者.约翰知道他的N(1≤N≤100)头奶牛中有一头总是说谎,其他的 ...

  9. 20162303实验三 敏捷开发与XP实践-1

    北京电子科技学院(BESTI) 实 验 报 告 课程:程序设计与数据结构 班级: 1623 姓名: 石亚鑫 学号:20162303 成绩: 2分 指导教师:娄嘉鹏 王志强 实验日期:5月12日 实验密 ...

  10. [USACO13NOV]No Change

    题目大意: 你有k(k<=16)个硬币,每个硬币都有自己的面值. 现在你要给n件商品付钱,每件商品也有自己的价格. 然而老板是个奸商,他绝对不会给你找钱. 你每次付钱只能用一个硬币,但是你可以一 ...