给ubuntu设置静态ip —— How to set static IP Address in Ubuntu Server 16.04
原文: 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.

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的更多相关文章
- 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 ...
- Ubuntu Server 16.04 安装MySQL并设置远程访问
Ubuntu Server 16.04 安装MySQL 1. 使用root账号 sudo apt-get install mysql-serversudo apt-get install mysql- ...
- 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(三):设置上传文件夹权限(这里测试用完全共享)
基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django 基于Ubuntu Server 16.04 LTS版本安装和部署Djan ...
- [原创]在HP DL380 G7服务器上部署基于Ubuntu Server 16.04 和 VirtualBox的云平台
对于一线开发人员来说,一提到虚拟机平台,往往会让人联想到在价格昂贵的服务器上部署VMware vSphere之类软件来实现. 笔者作为一个资深码农,也是一直梦寐着在自己家中打造一个真正的家庭私有云,秒 ...
- Ubuntu Server 16.04.1系统安装
一.Ubuntu Server 16.04.1系统安装 Ubuntu分为桌面版(desktop)和服务器版(Server),下面为大家介绍服务器版本Ubuntu Server 16.04.1的详细安装 ...
- 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(五):测试项目
基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django 基于Ubuntu Server 16.04 LTS版本安装和部署Djan ...
- 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(四):安装MySQL数据库
基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django 基于Ubuntu Server 16.04 LTS版本安装和部署Djan ...
- 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(二):Apache安装和配置
基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django 基于Ubuntu Server 16.04 LTS版本安装和部署Djan ...
- 从零到一,利用kubeadm在ubuntu server 16.04 64位系统离线安装kubernetes v1.10.0
说明 初步接触kubernets,记录学习过程 本教程目的利用kubeadm在ubuntu server 16.04 64位系统离线安装kubernets v1.10.0 环境信息 节点IP地址 角色 ...
随机推荐
- [BZOJ4025] 二分图 LCT/(线段树分治+并查集)
4025: 二分图 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 2667 Solved: 989[Submit][Status][Discuss] ...
- 将excel中的sheet1导入到sqlserver中
原文地址:C#将Excel数据表导入SQL数据库的两种方法作者:windream 方式一: 实现在c#中可高效的将excel数据导入到sqlserver数据库中,很多人通过循环来拼接sql,这样做不但 ...
- 0818JavaWeb基础
Java Web基础 JSP JSP --- Java Server Page 在服务器上运行的页面 动态网页(JSP网页) 与后台有数据交换的网页 ...
- linux——(1)初识linux
linux有窗口管理员环境和纯文本界面环境,同时linux默认提供6个Terminal来让用户登录.crtl+alt+F1-6可自由切换.其中如果窗口管理员环境处于运行状态,那么可以按crtl+alt ...
- 桌面笔记工具KeepNote
桌面笔记工具KeepNote 在渗透测试过程中,安全人员经常需要记录各种数据,如输出结果.运行截图.测试心得.这类信息格式多样,可能是图片.文字.文件等.为了便于管理这些内容,Kali Linux ...
- 一个应用 可以有多个application
韩梦飞沙 yue31313 韩亚飞 han_meng_fei_sha 313134555@qq.com 一个应用里面怎样才能有2个application 一个AndroidManifest.xml中可 ...
- POJ2505 A multiplication game 博弈论 找规律
http://poj.org/problem?id=2505 感觉博弈论只有找规律的印象已经在我心中埋下了种子... 题目大意:两个人轮流玩游戏,Stan先手,数字 p从1开始,Stan乘以一个2-9 ...
- [Lydsy1805月赛] quailty 算法
稍微建一下模型就可以发现,题目要求的其实是一个最小异或基环森林.... 可以用类似最小生成树的拟阵性质来证明,贪心的从小的边权开始依次尝试加入的方法是对的. 所以我们把a[]排完序之后直接递归贪心就行 ...
- [SRM568]DisjointSemicircles
题意:$2n$个位置排成一列,有一些位置已经填了数字($0\cdots n-1$中每个数字出现$0$次或$2$次),问是否存在一种填数方案使得用$n$个不相交的半圆可以把相同的数字连起来 首先把所有已 ...
- [xsy2238]snake
题意:给定一条折线,问能否在不扭曲它的情况下让它完全通过一个小孔 这个条件就是:过折线上任意一点$x$存在一条直线把折线分成不与直线相交的两部分,换句话说存在(与折线只有一个交点$x$)的直线 结论是 ...