原文: 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. Python基础系列----语法、数据类型、变量、编码

    1.基本语法                                                                                        Python ...

  2. js对象替换键值名称

    js对象替换键值名称 将obj中的id和name字段替换分别替换成为“@id”,“@name” 代码如下: let obj = [{id:,name:,name:"李四"}].ma ...

  3. LoadRunner11破解方法

    前期准备:LoadRunner11 下载LoadRunner破解文件 下载LoadRunner注册表清理工具 下载 LoadRunner11破解方法:一.覆盖破解文件首先请下载LoadRunner破解 ...

  4. Python中的多进程:fork和multiprocessing

    Python的多进程 套路1:os.fork() 先敲段代码: #!/usr/bin/env python3 import os os.fork() print('1111111111') 执行结果: ...

  5. css自媒体查询

    准备工作1:设置Meta标签 首先我们在使用Media的时候需要先设置下面这段代码,来兼容移动设备的展示效果: <meta name="viewport" content=& ...

  6. caffe-安装anaconda后重新编译caffe报错

    ks@ks-go:~/caffe-master$ make -j16 CXX/LD -o .build_release/tools/convert_imageset.bin CXX/LD -o .bu ...

  7. PAT L3-002. 堆栈

    树状数组,二分. 一堆数字,可以删除栈顶,压入数字,求中位数,可以线段树,也可以树状数组上二分. #include<map> #include<set> #include< ...

  8. Eclipse 主题(修改背景色)

  9. 解决vscode按下ctrl+S的时候自动格式化

    按下ctrl+S的时候自动格式化 为什么需要这种操作? 优点: 保存的时候格式化,让我们的代码自动格式化,减少人工调整. 缺点: 有一些打好包的JS有时候修改一下,但不需要格式化,因为打好包就是要压缩 ...

  10. poj 1050(矩阵求和问题dp)

    To the Max Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 44765   Accepted: 23700 Desc ...