Debian/Ubuntu网卡IP配置

  • 时间:2018-12-23 22:47 作者:图灵量子矩阵 来源:图灵量子矩阵 阅读:811
  • 扫一扫,手机访问
摘要:Linux Debian/Ubuntu网卡IP配置配置文件:/etc/network/interfacesauto loiface lo inet loopbackallow-hotplug eth0iface eth0 inet dhcpallow-hotplug eth1iface eth1 i

Linux

Debian/Ubuntu网卡IP配置

Debian/Ubuntu网卡IP配置

配置文件:/etc/network/interfaces

auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug eth1
iface eth1 inet static
address 192.168.56.223
netmask 255.255.255.0

---------------------------------

1、allow-hotplug 与 auto 的理论区别
auto
auto
在系统启动的时候启动网络接口,无论网络接口有无连接 (插入网线)。
假如该接口配置了 DHCP,则无论有无网线,系统都会去获取 DHCP。
并且假如没有插入网线,则等该接口超时后才会继续 DHCP。
allow-hotplug
allow-hotplug
只有当内核从网络接口检测到热插拔事件后才会启动该接口。假如系统开机时该接口没有插入网线,则系统不会启动该接口。
系统启动后,假如插入网线,系统会自动启动该接口。也就是将网络接口设置为热插拔模式。
Debian/Ubuntu网卡IP配置

1. 以DHCP方式配置网卡

编辑文件/etc/network/interfaces:

sudo vi /etc/network/interfaces

并用下面的行来替换有关eth0的行:

# The primary network interface - use DHCP to find our address

auto eth0

iface eth0 inet dhcp

用下面的命令使网络设置生效:

sudo /etc/init.d/networking restart

也可以在命令行下直接输入下面的命令来获取地址

sudo dhclient eth0

2. 为网卡配置静态IP地址

编辑文件/etc/network/interfaces:

sudo vi /etc/network/interfaces

并用下面的行来替换有关eth0的行:# The primary network interface

auto eth0

iface eth0 inet static

address 192.168.3.90

gateway 192.168.3.1

netmask 255.255.255.0

#network 192.168.3.0

#broadcast 192.168.3.255

将上面的ip地址等信息换成你自己即可以了.用下面的命令使网络设置生效:

sudo /etc/init.d/networking restart

3. 设定第二个IP地址(虚拟IP地址)

编辑文件/etc/network/interfaces:

sudo vi /etc/network/interfaces

在该文件中增加如下的行:

auto eth0:1

iface eth0:1 inet static

address 192.168.1.60

netmask 255.255.255.0

network x.x.x.x

broadcast x.x.x.x

gateway x.x.x.x

Debian/Ubuntu网卡IP配置

  • 全部评论(0)
最新发布的资讯信息
【系统环境|】2FA验证器 验证码如何登录(2024-04-01 20:18)
【系统环境|】怎么做才能建设好外贸网站?(2023-12-20 10:05)
【系统环境|数据库】 潮玩宇宙游戏道具收集方法(2023-12-12 16:13)
【系统环境|】遥遥领先!青否数字人直播系统5.0发布,支持真人接管实时驱动!(2023-10-12 17:31)
【系统环境|服务器应用】克隆自己的数字人形象需要几步?(2023-09-20 17:13)
【系统环境|】Tiktok登录教程(2023-02-13 14:17)
【系统环境|】ZORRO佐罗软件安装教程及一键新机使用方法详细简介(2023-02-10 21:56)
【系统环境|】阿里云 centos 云盘扩容命令(2023-01-10 16:35)
【系统环境|】补单系统搭建补单源码搭建(2022-05-18 11:35)
【系统环境|服务器应用】高端显卡再度登上热搜,竟然是因为“断崖式”的降价(2022-04-12 19:47)
手机二维码手机访问领取大礼包
返回顶部