日期:2014-05-16  浏览次数:20736 次

为linux配置另外一个IP地址

首先通过nano /etc/network/interface 编辑文件

?

#该部分是配置第一个iP地址

allow-hotplug eth0
iface eth0 inet static
address 192.168.61.112
netmask 255.255.248.0
gateway 192.168.60.1

#该部分是配置第二个iP地址,配置的原因是有可能你的数据库是配置在另外一个IP段的网络中,你的程序要进行访问
auto eth0:1
iface eth0:1 inet static
address 172.16.88.112
netmask 255.255.255.0

?

配置完成以后通过 :

root$:ifdown eth0:1 禁用网卡

root:$ifup eth0:1 开启网卡,可以使刚配置的网卡立即生效。