linux配置静态路由解决网络问题

今天,需要建立一个dblink,但一直没有成功,于是检查网络:

因为屏蔽了ping,所以用telnet试试:

[root@localhost root]# telnet 172.0.2.90
Trying 172.0.2.90...
telnet: connect to address 172.0.2.90: No route to host

看来是网络的问题。检查一下网卡的路由走向:

[root@localhost root]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
202.96.54.0 * 255.255.255.128 U 0 0 0 eth1
172.25.0.0 * 255.255.0.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 202.96.54.1 0.0.0.0 UG 0 0 0 eth1

发现没有为172.0网段配置路由,也没有为eth0配置默认路由(eth0是内网网卡、eth1是外网网卡)

为eth0手工配置静态路由:

[root@localhost root]# route add -net 172.0.0.0 netmask 255.255.0.0 gw 172.25.13.1 eth0

此时路由走向状况是:

[root@localhost root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
202.96.54.0 0.0.0.0 255.255.255.128 U 0 0 0 eth1
172.25.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
172.0.0.0 172.25.13.1 255.255.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 202.96.54.1 0.0.0.0 UG 0 0 0 eth1

再用telnet测试连接:

[root@localhost root]# route add -net 172.0.0.0 netmask 255.255.0.0 gw 172.25.13.1 eth0
[root@localhost root]# telnet 172.0.2.90
Trying 172.0.2.90...
Connected to 172.0.2.90.
Escape character is '^]'.

可见,网络已经是连通的了,dblink也可以正常访问数据了。