Debian路由4networking(2 ISP,2本地)

我有两个ISP:

  • 10.100.36.0/29
  • 10.200.36.0/29

我有我的两个networking:

  • 10.45.13.0/27
  • 10.45.15.0/27

我能够使用我的debian服务器路由1 ISP到我的networking。 但是,我们现在有2个局域网和2个ISP。

我想把从10.45.13.0/2710.100.36.0/2910.45.15.0/27所有内容都路由到10.200.36.0/29

我的debian服务器是一个DHCP服务器和DNS服务器。 它有4个NIC卡。 IP是:

  • 10.100.36.2(eth0)
  • 10.200.36.2(eth3)
  • 10.45.13.1(eth1)
  • 10.45.15.1(eth2)

自昨天以来,我一直在search谷歌,但我的解决scheme没有在这里,我barelly了解路由系统。

我的系统是全新的,

谢谢。

编辑

 root@ROUTER-DEB:/sst# ip route 10.200.36.0/29 dev eth3 proto kernel scope link src 10.200.36.2 metric 30 10.100.36.0/29 dev eth0 proto kernel scope link src 10.100.36.2 metric 40 10.45.15.0/27 dev eth2 proto kernel scope link src 10.45.15.1 metric 10 10.45.13.0/27 dev eth1 proto kernel scope link src 10.45.13.1 metric 10 default via 10.45.15.1 dev eth2 scope link metric 10 default via 10.45.13.1 dev eth1 scope link metric 10 default via 10.200.36.1 dev eth3 metric 30 default via 10.100.36.1 dev eth0 metric 40 

在这种情况下,您需要高级路由,源路由。 您需要两个路由表(每个ISP一个)和至less一个表select规则。

  1. 将两行添加到/etc/iproute2/rt_tables 。 数字不重要; 这只是为了使用名称。 我们来调用表isp_100和isp_200。
  2. 定义路由表:

     ip route add default via 10.100.36.1 table isp_100 ip route add 10.100.36.0/29 dev eth0 src 10.100.36.2 table isp_100 ip route add default via 10.200.36.1 table isp_200 ip route add 10.200.36.0/29 dev eth3 src 10.200.36.2 table isp_200 
  3. 定义表格select的规则

     ip rule add type unicast iif eth1 priority 100 table isp_100 ip rule add type unicast iif eth2 priority 101 table isp_200 

您可以使用from 10.45.13.0/27而不是iif eth1 。 如果没有超过eth1的10.45.13.0/27,则不起作用。 接口名称可能会更改。 但是如果后面创build的是10.45.13.0/27后面的子网,那么from 10.45.13.0/27就不from 10.45.13.0/27工作了。 另一方面:在这种情况下,这个系统上的路由select将不得不进行调整。 所以做出你的select。 最重要的是,你记得在networking(或系统硬件)发生变化的情况下你必须适应什么。

您的主路由表定义了系统本身(本地生成的数据包)如何连接到Internet。

每次重新启动networking子系统时,您都可能需要执行ip route命令的脚本。 我对openSUSE的经验是子系统重启不会影响ip rule设置。 所以这些可能需要在系统启动后只做一次。

您可以通过ip rule检查当前的规则,通过ip route table isp_100