Ubuntu双线双网卡双IP配置方法

阅读: 评论:0

2024年2月5日发(作者:)

Ubuntu双线双网卡双IP配置方法

Ubuntu-12.04-server版服务器

电信、联通双线接入

服务器环境如下:

操作系统:ubuntu-12.04-server

接入电信和联通的IP如下

电信(TEL)IP: 58.57.65.239; 子网掩码: 255.255.255.128; 网关:58.57.65.129

联通(CNC)IP: 61.133.41.239; 子网掩码: 255.255.255.192; 网关:61.133.41.193

操作步骤如下

1、 配置网卡信息

运行命令vi /etc/network/interfaces把里面的配置修改为如下

auto lo

iface lo inet loopback

auto eth0

iface eth0 inet static

address 61.133.41.239

netmask 255.255.255.192

auto eth1

iface eth1 inet static

address 58.57.65.239

netmask 255.255.255.128

gateway 58.57.65.129

保存配置信息并且得启网卡

/etc/init.d/networking restart

2、 增加电信tel和联通cnc的路由表

vi /etc/iproute2/rt_tables

里面已经显示了部分路由信息,在他的后面加上下面2句,保存退出(251、252可以是1-254之间任意数字,但不能与路由表已有的一样)

252 tel

251 cnc

3、 增加路由规则,运行下面6个命令,前3个是设置电信网关,让电信的数据从eth1网卡走,后3个是设置联通网关,让数据从eth0走

ip route flush table tel

ip route add default via 58.57.65.129 dev eth1 src 58.57.65.239 table tel

ip rule add from 58.57.65.239 table tel

ip route flush table cnc

ip route add default via 61.133.41.193 dev eth0 src 61.133.41.239 table cnc

ip rule add from 61.133.41.239 table cnc

4、 运行命令vi /etc/init.d/networking配置脚本文件在exit 0前加入如下内容,其实就是刚才

增加的路由规则。

ip route flush table tel

ip route add default via 58.57.65.129 dev eth1 src 58.57.65.239 table tel

ip rule add from 58.57.65.239 table tel

ip route flush table cnc

ip route add default via 61.133.41.193 dev eth0 src 61.133.41.239 table cnc

ip rule add from 61.133.41.239 table cnc

5、 重启网络运行/etc/init.d/networking restart

6、写入系统启动脚本运行命令vi /etc/,配置脚本文件在exit 0前加入如下内容(也就是添加步骤4的路由规则)

ip route flush table tel

ip route add default via 58.57.65.129 dev eth1 src 58.57.65.239 table tel

ip rule add from 58.57.65.239 table tel

ip route flush table cnc

ip route add default via 61.133.41.193 dev eth0 src 61.133.41.239 table cnc

ip rule add from 61.133.41.239 table cnc

Ubuntu双线双网卡双IP配置方法

本文发布于:2024-02-05 18:12:51,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170712797157885.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:配置   路由   运行   信息   不能
留言与评论(共有 0 条评论)
   
验证码:
排行榜

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23