Linux服务器双网卡双IP和单网卡双IP配置方法(Debian/Ubuntu)

一、双网卡双IP

eth0为电信,eth1为联通。

# cd /etc/network/

# vi 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

 

auto eth0

iface eth0 inet static

address 114.80.0.4

netmask 255.255.255.128

gateway 114.80.0.3

 

auto eth1

iface eth1 inet static

address 112.65.0.2

netmask 255.255.255.0

######################################################

然后做策略路由。

二、单网卡双IP

# This file describes the network interfaces availableon your system

# and how to activate them. For more information, see interfaces(5).

#/etc/network/interfaces

 

# The loopback network interface

auto lo

iface lo inet loopback

 

auto eth0

iface eth0 inet static

address 192.168.1.116

netmask 255.255.255.0

gateway 192.168.1.2

broadcast 192.168.1.255

# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 61.134.1.4

 

 

auto eth0:1

iface eth0:1 inet static

address 192.168.1.135

netmask 255.255.255.0

gateway 192.168.1.2

broadcast  192.168.1.255

/etc/init.d/networking restart重启服务

然后做策略路由。

三、配置策略路由。

Ubuntudebian的开机自启动服务和redhatcentos都不一样,ubuntudebian 只需把写好的脚本放到指定目录下就可以了! 

相关的操作步骤如下:

把路由列表文件static-routes.sh放置在/etc/init.d目录中,赋予可执行权限,然后执行一下。

cd /etc/init.d

chmod +x /etc/init.d/static-routes.sh

./ static-routes.sh

update-rc.d static-routes.sh  start 99 2 3 4 5 . stop 01 0 1 6 .

#表示2345这五个运行级别中,由小到大第二十个运行static-routes.sh 

#016三个级别中,第一个关闭static-routes.sh

#注意它有2个点号,效果等于下面方法:

update-rc.d static-routes.sh defaults

使用update-rc.d 命令来控制具体的加入,有点类似于redhat下的chkconfig命令)

删除执行下面的命令:

update-rc.d -f static-routes.sh remove

完成后重启服务器,测试路由信息是否失效


你可能感兴趣的:(负载均衡,高可用,Bond,双网卡)