当前位置: > Linux发行版 > Debian >

Debian7 单网卡多IP配置详解

时间:2021-12-18 16:48来源:linux.it.net.cn 作者:IT

编辑/etc/network/interfaces配置文件,添加以下内容:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.10.56
netmask 255.255.254.0
gateway 192.168.10.1

auto eth0:0
address 192.168.11.250
netmask 255.255.254.0

重启网络:

/etc/init.d/networking restart

如果一个网卡有2个默认网关,将会不转发数据,具体原理想想ip路由过程应该可以明白。因此正确的做法是,去掉eth0:0中的gateway,然后在route那里添加gateway即可。



(责任编辑:IT)
------分隔线----------------------------