原文: 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. AC日记——Mato的文件管理 bzoj 3289

    3289 思路: 莫队求区间逆序对个数,树状数组维护: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 500 ...

  2. CentOS7下Samba的安装与配置

    一.Samba简介 Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成.SMB(Server Messages Block,信息服务块)是一种在局域网上共享 ...

  3. destoon 部署到服务器如何修改密码使网站能正常访问登录

    1.根目录的config.inc.php  修改 db_pass 2.缓存文件 根目录/file/cache/module-2.php   修改 uc_dbpwd PS:不一定都在module-2.p ...

  4. 阅读 CMakeLists

    新手,入门阅读 CMakeLists,希望读者能给点建议 发现两篇文章,我感觉很好~ <阅读 CMakeLists>(下面只copy此篇)文章来源:http://blog.sina.com ...

  5. 抽丝剥茧:理解Android权限机制

    前一段时间面试官问我Android在Linux的基础上,权限做了哪些改变.霹雳呱啦说了一堆,但是说着说着,始终感觉自己说的缺了点东西,自己理解还是不够到位,而且网上的很多文章在原理上基本都是大同小异, ...

  6. WebService的网络协议

    SOAP协议.XML-RPC以及Hessian 是WebService的主要传输(编码)协议 SOAP即简单对象访问协议(Simple Object Access Protocol),它是用于交换XM ...

  7. 【UOJ #198】【CTSC 2016】时空旅行

    http://uoj.ac/problem/198 (先补一下以前的题解) 这道题5分暴力好写好调,链上部分分可以用可持久化线段树,每次旅行\(x\)值相同的可以用标记永久化线段树.我还听到某些神犇说 ...

  8. 【高斯消元解xor方程】BZOJ1923-[Sdoi2010]外星千足虫

    [题目大意] 有n个数或为奇数或为偶数,现在进行m次操作,每次取出部分求和,告诉你这几次操作选取的数和它们和的奇偶性.如果通过这m次操作能得到所有数的奇偶性,则输出进行到第n次时即可求出答案:否则输出 ...

  9. python 多继承详解

    class A(object): # A must be new-style class def __init__(self): print "enter A" print &qu ...

  10. go环境变量配置liteide配置

    1.go环境变量配置 http://download.csdn.net/detail/defonds/9408855下载后直接安装如果都选默认就只要添加一个gopath就可以了 不是默认添加goroo ...