三三世界-百宝箱

文章 分类 标签
130 9 247

公告

暂无站点公告

Linux Debian 系统的单网卡绑定多个IP地址的操作步骤

三三 2022-04-17 2306 0条评论 Linux使用 添加Ip地址debianubuntu

首页 / 正文

在Debian系统下添加新IP,你只需要修改下 /etc/network/interfaces 文件就可以了,即在eth0接口上绑定更多的IP地址。

我们首先要编辑网卡添加新IP地址的配置文件,命令如下:

sudo vi /etc/network/interfaces

如果安装了nano更方便一些使用:

nano /etc/network/interfaces

输入以上命令之后,我们就进入了编辑器修改配置文件的界面。
举例:
单网卡“eth0”添加“192.168.1.2”和“192.168.1.3”这2个IP为例进行演示,命令代码如下:

注意,这里很重要,几个ip就加上几个:

auto eth0
auto eth0:0
auto eth0:1

#默认网卡eth0的IP地址

iface eth0 inet static
address 192.168.1.1 #主机IP地址
netmask 255.255.255.0 #子网掩码
gateway 192.168.1.254 #网关地址

#为网卡eth0的增加第1个IP地址

iface eth0:0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254

#为网卡eth0的增加第2个IP地址

iface eth0:1 inet static
address 192.168.1.3
netmask 255.255.255.0
gateway 192.168.1.254

当以上内容编辑完成后,执行如下命令生效:

sudo /etc/init.d/networking restart

如果以上命令执行失败,重启服务器即可。

参考样板:
打开文件编辑

nano /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
auto eno1
auto eno1:1
auto eno1:2
auto eno1:3
auto eno1:4
iface lo inet loopback

# The primary network interface
allow-hotplug eno1
iface eno1 inet static
        address 1.209.190.202/29
        gateway 1.209.190.201

iface eno1:1 inet static
        address 1.209.190.203/29
        gateway 1.209.190.201

iface eno1:2 inet static
        address 1.209.190.204/29
        gateway 1.209.190.201

iface eno1:3 inet static
        address 1.209.190.205/29
        gateway 1.209.190.201

iface eno1:4 inet static
        address 1.209.190.206/29
        gateway 1.209.190.201
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8

重启网络

/etc/init.d/networking restart

评论(0)

当前没有评论,还不快来留下第一个脚印吧


Copyright 2021 三三世界-百宝箱. All Rights Reserved.

最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年05月

   1234
567891011
12131415161718
19202122232425
262728293031 

文章目录

上一张 下一张