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

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

然后做策略路由。

三、配置策略路由。

Ubuntu、debian的开机自启动服务和RedHat、CentOS都不一样,Ubuntu、debian需把写好的脚本放到指定目录! 

步骤如下:

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

cd /etc/init.d

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

./static-routes.sh     #带路由信息的shell脚本

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

#表示在2、3、4、5这五个运行级别中,由小到大,第二十个运行static-routes

#在0、1、6三个级别中,第一个关闭static-routes

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

update-rc.d static-routes defaults

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

sudo apt-get install sysv-rc-conf     

(一个强大的服务管理程序,有点类似RedHat下ntsysv与setup)

使用sysv-rc-conf检查static-routes是否添加并启动

163631_f45v_1437015.png

清除开机启动设置执行下面的命令:

update-rc.d -f static-routes remove

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

转载于:https://my.oschina.net/HeAlvin/blog/544071

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Debian GNU/Linux, Ubuntu Linux, Fedora Core / Red Hat Linux, OpenSUSE / SuSE Linux, 和 Mandrake Linux (现在称为Manjaro) 都是Linux发行版,它们各自有特色,用于满足不同用户的需求。 1. Debian GNU/Linux: 作为开源软件的基石,Debian以其稳定性、安全性以及严格的版本管理和软件质量控制而著名。它是许多其他发行版(如Ubuntu)的基础。 2. Ubuntu Linux: 是基于Debian的高级用户友好发行版,以其易于安装和使用、定期更新以及社区支持而知名。Ubuntu特别适合新手和企业环境。 3. Fedora Core / Red Hat Linux: Red Hat Linux已演变成Red Hat Enterprise Linux (RHEL),而Fedora则作为RHEL的开发分支。Fedora是滚动更新的,注重最新技术和创新,常被用作测试新软件和技术的平台。 4. OpenSUSE Linux: 始终以易用性和高度定制性著称,OpenSUSE提供了多个版本供选择,包括用于商业和个人用户的开源版本,以及针对服务器和嵌入式设备的定制版本。 5. Mandrake Linux (现为Manjaro): 曾经是Mandriva Linux的一个分支,后来独立出来。Manjaro以其友好的界面、轻量级以及对新手友好而闻名,它基于Arch Linux但提供了更平滑的用户体验。 如果你想深入了解这些发行版中的某个,或者它们之间的差异,可以关注它们的桌面环境(如GNOME、KDE、XFCE)、软件包管理器(如apt、dnf)、社区支持以及针对特定应用场景的定制程度。是否有特别感兴趣的地方?

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值