原文: 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. 计划任务at cron

    计划任务作用:做一些周期性的任务,主要用于定时备份数据,同步时间,定时删除日志 所有计划任务执行的输出都会以邮件的方式发送给指定用户,除非重定向 (1)at:一次性调度执行 1)安装 yum inst ...

  2. python访问web的利器:urllib2

    使用Python访问网页主要有三种方式: urllib, urllib2, httpliburllib比较简单,功能相对也比较弱,httplib简单强大,但好像不支持session1. 最简单的页面访 ...

  3. 2017 Multi-University Training 2 解题报告

    Is Derek lying? Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  4. [NOIp2016提高组]蚯蚓

    题目大意: 给你n个不同长度蚯蚓,每秒从里面取出最长的砍下u/v变成两只,又把剩下的加长q. 问你在m之前的t,2t,3t...的时间上,砍的蚯蚓长度, 以及m秒后剩下所有的蚯蚓长度. 思路: 很容易 ...

  5. Mac下的MySQL修改默认连接字符集

    进入命令行执行以下命令: sudo vim /etc/my.cnf [client] default-character-set=utf8 [mysqld] character-set-server= ...

  6. #Java Web累积#表格<table>中隐藏列做备用数据

    初入JW,MyEclipse,JS文件中码砖时怎么连个提示都没有. 步骤1 JSP代码中,Table多出一列,如下列代码中的 Other,其中css文件中将col00的width设置为0px; < ...

  7. inno setup 脚本常用修改 转

    http://blog.sina.com.cn/s/blog_72c2eb350100y2sa.html 有人提及想更换安装界面的图片,其实方法很简单,只需要修改inno setup安装目录下的Wiz ...

  8. file结构体中private_data指针的疑惑

    转:http://www.360doc.com/content/12/0506/19/1299815_209093142.shtml hi all and barry, 最近在学习字符设备驱动,不太明 ...

  9. tomcat配置优化

    tomcat服务管理页面 http://192.168.1.249:8080/manager/status 找到下面的内容 "http-nio-8081"  (此处端口是根据自己实 ...

  10. FORM动态LIST ITEM

    DECLARE rg_list_item recordgroup; ret_code NUMBER; BEGIN --SQL里必做是以值键两个字段顺序,并且都要为字符串类型 rg_list_item ...