Ubuntu 16.04 配置单网卡绑定多IP
Ubuntu 16.04 配置单网卡绑定多IP
操作系统
Ubuntu 16.04 LTS
一、单个网卡配置多个IP
//在 /etc/network/ 目录下编辑 interfaces 文件
root@ubuntu:~# vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0 //这台主机只有 eth0 这张网卡
iface eth0 inet static
address 192.168.121.24
netmask 255.255.255.0
gateway 192.168.121.2
auto eth0:0 //配置子ip eth0:0
iface eth0:0 inet static
address 192.168.121.25
netmask 255.255.255.0
auto eth0:1 //配置子ip eth0:1
iface eth0:1 inet static
address 192.168.121.26
netmask 255.255.255.0
auto eth0:2 //配置子ip eth0:2 ;接着可以依次类推
iface eth0:2 inet static
address 192.168.121.27
netmask 255.255.255.0
二、添加 DNS 配置
//DNS服务需要在 /etc/resolvconf/resolv.conf.d/head
或者在/etc/resolvconf/resolv.conf.d/base (二者任选其一)
方法一:
root@ubuntu:~# vim /etc/resolvconf/resolv.conf.d/head
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.121.2 //添加这一行
//保存退出后执行:resolvconf -u ;立即生效
root@ubuntu:~# resolvconf -u //一定要执行这条命令,否则无效
方法二:
echo "nameserver x.x.x.x" >> /etc/resolvconf/resolv.conf.d/base
echo "nameserver x.x.x.x" >> /etc/resolvconf/resolv.conf.d/head //任选其一;将 x.x.x.x 换成 DNS
resolvconf -u
三、重启网络服务
//重启网络服务
root@ubuntu:~# systemctl restart networking.service
//查看IP信息
root@ubuntu:~# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:16:c5:69 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.24/24 brd 192.168.121.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.121.25/24 brd 192.168.121.255 scope global secondary eth0:0
valid_lft forever preferred_lft forever
inet 192.168.121.26/24 brd 192.168.121.255 scope global secondary eth0:1
valid_lft forever preferred_lft forever
inet 192.168.121.27/24 brd 192.168.121.255 scope global secondary eth0:2
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe16:c569/64 scope link
valid_lft forever preferred_lft forever
Ubuntu 16.04 配置单网卡绑定多IP的更多相关文章
- ubuntu 16.04 添加网卡
root@ubuntu:~# ls /sys/class/net/ enp0s3 enp0s8 lo root@ubuntu:~# vim /etc/network/interfaces # This ...
- ubuntu 16.04 修正网卡与ifname对应关系
一台工控机,含有6个网口,但是名称 enp3s0 等等与网口顺序对应不起来. 现在修改脚本 /etc/udev/rules.d/70-persistent-net.rules ,如果文件不存在,可以 ...
- ubuntu 16.04 修改网卡显示名称
~# sudo nano /etc/default/grub找到:GRUB_CMDLINE_LINUX=""改为:GRUB_CMDLINE_LINUX="net.ifna ...
- ubuntu16.04 双网卡绑定
ubuntu 16.04 双网卡绑定仅仅需要配置/etc/network/interfaces 添加标记内容即可 apt-get install ifenslave 默认已经安装
- 在ubuntu 16.04 的vm中添加新网卡,同一网段不同ip
在ubuntu 16.04 的vm中添加新网卡,同一网段不同ip 来源 https://blog.51cto.com/744478/2083672 在ubuntu 16.04 的vm中新加了一块网卡, ...
- Ubuntu 16.04修改配置静态IP和DNS
Ubuntu 16.04修改配置静态IP和DNS 1.修改interfaces 文件 sudo gedit /etc/network/interfaces 2.添加 例如: auto enp0s25 ...
- VMWare虚拟机中Ubuntu 16.04 (linux无桌面)配置静态IP上网
1. 基础环境说明 虚拟机: VMWare 12.5.2 操作系统: Ubuntu 16.04 (无桌面) 物理主机操作系统: win 7 旗舰版 2. 摸底 VMware在安装之后,会创建2个虚拟的 ...
- ubuntu各系统双网卡绑定
Ubuntu14.04双网卡绑定 2.1 确定网卡名称 首先确定两块网卡的名称,一般为eth0.eth1,如果有自己添加的网卡名称可能不同,在安装系统的时候可以看到,通过ipmaddr命令可以查看所有 ...
- Linux/Ubuntu 16.04 使用校园网客户端Dr.com DrClient 有线连网,同时开启WiFi热点
前面写过Ubuntu 16.04 使用校园网客户端 DrClient 无线上网,在这篇文章中将要介绍下,在Ubuntu 16.04上如何使用校园网客户端实现有线登录,这个问题也让博主困惑了很久,但是问 ...
随机推荐
- 使用Vscode 开发调试 C/C++ 项目
需要安装的扩展 C/C++ 如果是远程 Linux上开发还需要安装 Remote Development 创建工作目录后,代码远程克隆... 省略.. 创建项目配置文件,主要的作用是代码智能提示,错误 ...
- Distributed | Paxos
自Paxos问世以来就持续垄断了分布式一致性算法,Paxos这个名词几乎等同于分布式一致性.Google的很多大型分布式系统都采用了Paxos算法来解决分布式一致性问题.在学习了Raft算法之后自然不 ...
- Markdown部分用法总结
1.Markdown数学公式&符号 2.Cmd Markdown 公式指导手册
- 记docker安装和ida远程调试问题
docker安装 1.卸载可能存在的旧版本: sudo apt-get remove docker docker-engine docker-ce docker.io 如果想要彻底卸载docker ...
- 大学四年,总结一套适合小白的Java自学路线和方法
前言篇 大家好,我是bigsai 好久不见,甚是想念,文章同时收录在回车课堂(文底阅读原文可达). 无论你是大学生还是在职人员,想学Java时,都会面临两个选择,自学或者报班.报班通常太费钱,时间又不 ...
- Ubuntu 快速安装Gitlab-ce
1.下载并安装gitlab,下载地址: https://packages.gitlab.com/gitlab/gitlab-ce/ sudo dpkg -i gitlab-ce_12.0.3-ce.0 ...
- Python 基础教程 —— 网络爬虫入门篇
前言 Python 是一种解释型.面向对象.动态数据类型的高级程序设计语言,它由 Guido van Rossum 于 1989 年底发明,第一个公开发行版发行于 1991 年.自面世以后,Pytho ...
- 866. Prime Palindrome
Find the smallest prime palindrome greater than or equal to N. Recall that a number is prime if it's ...
- 031- 控制语句switch
语法 switch(表达式){ case 值1: java语句; break; case 值2: java语句; break; case 值3: java语句; break; default: jav ...
- 【ElasticSearch】ES线上脏数据处理
ES分组 GET index_user_latest/_search { "aggs": { "group_by_tags": { "terms&qu ...