我正在尝试为我们的 SIP 电话将第二个 ISP 连接连接到我的服务器。
eth0
在192.168.1.x上有我们默认的 25Mb 服务,我已经配置了
eth1
新的 6Mb 服务为10.10.1.x
两台路由器都配置了具有唯一静态 IP 的 pppoe,我有单独的交换机,以及一台带有两个以太网端口的 Ubuntu 14Lts 服务器。单独连接的任何一个都可以正常工作,但是两者都可以,我只能ping -I eth[0|1] 8.8.8.8 -c 3
在一个接口上但是ping每个路由器没有问题。
如果有人可以帮助我让 Nic 启动并运行并默认主要流量通过eth0
和 Just Asterisk/Sip 流量通过eth1
将节省我的一天。
一些信息输出:
# cat /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.100
gateway 192.168.1.1
netmask 255.255.255.0
auto eth1
iface eth1 inet static
address 10.10.1.101
#gateway 10.10.1.1
netmask 255.255.255.0
$ sudo route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default home.Home 0.0.0.0 UG 0 0 0 eth1
10.10.1.0 * 255.255.255.0 U 1 0 0 eth1
link-local * 255.255.0.0 U 1000 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
$ sudo ifdown eth0 && sudo ifup eth0
RTNETLINK answers: No such process
RTNETLINK answers: File exists
Failed to bring up eth0.
$ sudo ifdown eth1 && sudo ifup eth1
ifdown: interface eth1 not configured
RTNETLINK answers: File exists
Failed to bring up eth1.
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:25:90:11:c8:44
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::225:90ff:fe11:c844/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2316517 errors:0 dropped:0 overruns:0 frame:0
TX packets:3877952 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1881181270 (1.8 GB) TX bytes:5573716194 (5.5 GB)
Interrupt:16 Memory:faee0000-faf00000
eth1 Link encap:Ethernet HWaddr 00:25:90:11:c8:45
inet addr:10.10.1.101 Bcast:10.10.1.255 Mask:255.255.255.0
inet6 addr: fe80::225:90ff:fe11:c845/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:214622 errors:0 dropped:0 overruns:0 frame:0
TX packets:9763 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13988405 (13.9 MB) TX bytes:890576 (890.5 KB)
Interrupt:16 Memory:fafe0000-fb000000
======================编辑1: ========================= ==
感谢 Peter Zhabin 的 iproute2 说明
apt-get install iproute2
echo "1 link2" >> /etc/iproute2/rt_tables
ip route add 10.10.1.0/24 dev eth1 src 10.10.1.101 table link2
ip route add default via 10.10.1.1 dev eth1 table link2
ip rule add from 10.10.1.101/32 table link2
ip rule add to 10.10.1.101/32 table link2
我第一次尝试时有点奇怪sudo echo "1 link2" >> /etc/iproute2/rt_tables
-bash: /etc/iproute2/rt_tables: Permission denied 但我切换到 Root 以避免需要 sudo 并且没有进一步的投诉。
======================编辑2: ========================= ==
# ping -I 10.10.1.101 8.8.8.8 -c 3
PING 8.8.8.8 (8.8.8.8) from 10.10.1.101 : 56(84) bytes of data.
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2014ms
======================编辑3: ======================== ==
# ip rule show
0: from all lookup local
32764: from all to 10.10.1.101 lookup link2
32765: from 10.10.1.101 lookup link2
32766: from all lookup main
32767: from all lookup default
# ip route show
default via 192.168.1.1 dev eth0
10.10.1.0/24 dev eth1 proto kernel scope link src 10.10.1.101
169.254.0.0/16 dev eth1 scope link metric 1000
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
# ip route show table link2
default via 10.10.1.1 dev eth1
10.10.1.0/24 dev eth1 scope link src 10.10.1.101
显示link2 表奇怪的是有点碰巧。我不明白为什么它并不总是打印。好消息是通过 IP 进行 Ping 工作,尽管 eth1 没有。为了完成,我还包括完整的展示表
# ip route show table all
default via 10.10.1.1 dev eth1 table link2
10.10.1.0/24 dev eth1 table link2 scope link src 10.10.1.101
default via 192.168.1.1 dev eth0
10.10.1.0/24 dev eth1 proto kernel scope link src 10.10.1.101
169.254.0.0/16 dev eth1 scope link metric 1000
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
broadcast 10.10.1.0 dev eth1 table local proto kernel scope link src 10.10.1.101
local 10.10.1.101 dev eth1 table local proto kernel scope host src 10.10.1.101
broadcast 10.10.1.255 dev eth1 table local proto kernel scope link src 10.10.1.101
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
broadcast 192.168.1.0 dev eth0 table local proto kernel scope link src 192.168.1.100
local 192.168.1.100 dev eth0 table local proto kernel scope host src 192.168.1.100
broadcast 192.168.1.255 dev eth0 table local proto kernel scope link src 192.168.1.100
broadcast 192.168.122.0 dev virbr0 table local proto kernel scope link src 192.168.122.1
local 192.168.122.1 dev virbr0 table local proto kernel scope host src 192.168.122.1
broadcast 192.168.122.255 dev virbr0 table local proto kernel scope link src 192.168.122.1
fe80::/64 dev eth0 proto kernel metric 256
fe80::/64 dev eth1 proto kernel metric 256
unreachable default dev lo table unspec proto kernel metric 4294967295 error -101
local ::1 dev lo table local proto none metric 0
local fe80::225:90ff:fe11:c844 dev lo table local proto none metric 0
local fe80::225:90ff:fe11:c845 dev lo table local proto none metric 0
ff00::/8 dev eth0 table local metric 256
ff00::/8 dev eth1 table local metric 256
unreachable default dev lo table unspec proto kernel metric 4294967295 error -101
# ping -I eth1 8.8.8.8 -c 3
PING 8.8.8.8 (8.8.8.8) from 10.10.1.101 eth1: 56(84) bytes of data.
From 10.10.1.101 icmp_seq=1 Destination Host Unreachable
From 10.10.1.101 icmp_seq=2 Destination Host Unreachable
From 10.10.1.101 icmp_seq=3 Destination Host Unreachable
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2015ms
pipe 3
# ping -I 10.10.1.101 8.8.8.8 -c 3
PING 8.8.8.8 (8.8.8.8) from 10.10.1.101 : 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=60 time=29.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=60 time=29.3 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=60 time=28.8 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 28.804/29.192/29.433/0.310 ms