侧边栏壁纸
博主头像
WinJay博主等级

博观而约取 厚积而薄发

  • 累计撰写 319 篇文章
  • 累计创建 169 个标签
  • 累计收到 1 条评论
隐藏侧边栏

Ubuntu单个网卡绑定多个ip

WinJay
2013-07-26 / 0 评论 / 0 点赞 / 95 阅读 / 1,271 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2021-04-08,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

常常我们有需要一个网卡像windows一样设置多个IP。

下面我们看看在ubuntu下怎么样做.

我们先打开网络接口的文件
sudo vi /etc/network/interfaces
会看到
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface auto eth0
iface eth0 inet static
address 202.205.XXX.XX
netmask 255.XXX.XXX.X
network 202.205.XXX.XX
broadcast 202.205.XXX.XXX
gateway 202.205.XXX.XX
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.205.XXX.XX

照上边eth0添加eth0:0

auto eth0:0
iface eth0:0 inet static
name Ethernet
address 202.205.XXX.XX
netmask 255.XXX.XXX.X
network 202.205.XXX.XX
broadcast 202.205.XXX.XXX
gateway 202.205.XXX.XX
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.205.XXX.XX

重启服务
sudo /etc/init.d/networking restart
测试新的ip地址是否生效
ping 202.205.XXX.XX
ping
202.205.XXX.XX

==============以上为添加同一网段内的IP地址=================

0

评论区