Debian下绑定、添加多IP的方法(单网卡)

sudo nano /etc/network/interfaces

进入文件之后点击i进入编辑模式,仿照如下添加第二个ip(enp6s0是网卡,根据个人系统情况修改),有的系统是allow-hotplug,可以直接修改为auto

auto enp6s0
iface enp6s0 inet static
        address 192.168.0.1
        netmask 255.255.255.248
        gateway 204.12.220.225
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8
        dns-search opthappiness.com
auto enp6s0:1
iface enp6s0:1 inet static
        address 192.168.0.2
        netmask 255.255.255.248
auto enp6s0:2
iface enp6s0:2 inet static
        address 192.168.0.3
        netmask 255.255.255.248
auto enp6s0:3
iface enp6s0:3 inet static
        address 192.168.0.4
        netmask 255.255.255.248
auto enp6s0:4
iface enp6s0:4 inet static
        address 192.168.0.5
        netmask 255.255.255.248

注意,新增ip不要写gateway(网关),如果还要继续添加ip,同理再在下面添加enp6s0:5、enp6s0:6….

保存文件,并执行如下命令刷新网络

# /etc/init.d/networking restart

或者:

$ sudo /etc/init.d/networking restart

版权声明:
作者:José
链接:https://www.josejang.com/about-work/286.html
来源:José's ⎝⏠⏝⏠⎠ Blog
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>