如何做到通过指定的网卡访问指定IP地址?
我现在有个问题想请教:
我有台ubuntu的Linux的电脑有2个网卡,LAN1网卡的固定IP是10.133.10.7,LAN2网卡的固定IP是10.10.160.7,
以下是/etc/rc.local文件的内容
ip route flush table ZJZYL
ip route add default via 10.133.10.62 dev eth0 src 10.133.10.7 table ZJZYL
ip rule add from 10.133.10.7 table ZJZYL
ip route flush table VPN
ip route add default via 10.10.160.254 dev eth1 src 10.10.160.7 table VPN
ip rule add from 10.10.160.7 table VPN
/etc/network/interfaces文件的内容:
#eth0_LAN1<-->ZJZYL
auto eth0
iface eth0 inet static
address 10.133.10.7
netmask 255.255.255.192
gateway 10.133.10.62
#eth1_LAN2<-->R86 3G VPN
auto eth1
iface eth1 inet static
address 10.10.160.7
netmask 255.255.255.0
#gateway 10.10.160.254
#dns-nameservers 10.133.10.62
root@ubuntu:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.133.10.62 0.0.0.0 UG 100 0 0 eth0
10.10.160.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
10.133.10.0 0.0.0.0 255.255.255.192 U 0 0 0 eth0
LAN1连接的是一个内网,LAN2通过一个路由连接上互联网;
现在要求这个linux主机连接一个固定的公网IP A[假设为1,2,3,4]的服务器,要求访问公网IP A的数据由LAN2网卡走,但是又不能修改原来的默认网关[10.133.10.62]
总之,在不改变默认网关的情况下,如何做到通过指定的网卡访问指定IP地址?