在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
版权属于: 三三世界-百宝箱
本文链接: http://33f.net/linux/debian_add_ips.html
本文最后更新于2022年07月17日 ,已超过888天没有更新,若内容或图片失效,请留言反馈。
本文允许转载,但请在转载时请以超链接或其它形式标明文章出处
@Doug Shume it's ok for me , you can post here.
Saved as a favorite, I like your website!
If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.
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!
Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.
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.
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 怎么办啊