|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!情况简述:
办事器A具有双网卡,装置操纵体系RHEL6.3
----------------------------------------------------------
网卡显现称号IP地点网关
----------------------------------------------------------
eth0192.168.153.4192.168.153.1
eth1192.168.152.4192.168.152.1
-----------------------------------------------------------
网卡设置文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@clovem~]#cat/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.168.153.4
NETMASK=255.255.255.0
GATEWAY=192.168.153.1
[root@clovem~]#cat/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.168.152.4
NETMASK=255.255.255.0
GATEWAY=192.168.152.1
重启收集办事
[root@clovem~]#servicenetworkrestart
检察其路由信息:
[root@clovem~]#route
KernelIProutingtable
DestinationGatewayGenmaskFlagsMetricRefUseIface
192.168.153.0*255.255.255.0U000eth0
192.168.152.0*255.255.255.0U000eth1
link-local*255.255.0.0U101500eth0
link-local*255.255.0.0U101600eth1
default192.168.152.1255.255.255.0UG101700eth1
能够发明双网卡的默许网关为192.168.152.1
从其他网段192.168.151.0/24的某台测试机:192.168.150.252
会见192.168.153.4和192.168.152.4,只能经由过程192.168.152.4举行收集毗连,而192.168.153.4却不成以,从下面的路由表中能够看出两个网卡设置文件中的网关参数只要192.168.152.1失效,并被设置为默许网关。
办理***:
1.将两个网卡设置文件中的GATEWAY参数全体删除,即
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@clovem~]#cat/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.168.153.4
NETMASK=255.255.255.0
[root@clovem~]#cat/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.168.152.4
NETMASK=255.255.255.0
2.重启收集
[root@clovem~]#servicenetworkrestart
3.检察路由表
[root@clovem~]#route
KernelIProutingtable
DestinationGatewayGenmaskFlagsMetricRefUseIface
192.168.153.0*255.255.255.0U000eth0
192.168.152.0*255.255.255.0U000eth1
link-local*255.255.0.0U101500eth0
link-local*255.255.0.0U101600eth1
发明默许网关没有被设置
4.增加静态路由表
1
2
3
4
5
6
7
8
[root@clovem~]#echo"153net_153">>/etc/iproute2/rt_tables
[root@clovem~]#echo"152net_152">>/etc/iproute2/rt_tables
[root@clovem~]#iprouteflushtablenet_153
[root@clovem~]#iprouteadddefaultvia192.168.153.1deveth0src192.168.153.4tablenet_153
[root@clovem~]#ipruleaddfrom192.168.153.4tablenet_153
[root@clovem~]#iprouteflushtablenet_152
[root@clovem~]#iprouteadddefaultvia192.168.152.1deveth0src192.168.153.4tablenet_152
[root@clovem~]#ipruleaddfrom192.168.152.4tablenet_152
5.此时再次经由过程内部测试机会见都可
1
2
3
4
5
6
7
8
9
[root@storage252~]#ifconfigeth0
eth0Linkencap:EthernetHWaddr00:50:56:82:56:55
inetaddr:192.168.150.252Bcast:192.168.150.255Mask:255.255.255.0
inet6addr:fe80::250:56ff:fe82:5655/64Scope:Link
UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
RXpackets:25910143errors:0dropped:0overruns:0frame:0
TXpackets:19888495errors:0dropped:0overruns:0carrier:0
collisions:0txqueuelen:1000
RXbytes:26258149440(24.4GiB)TXbytes:16323278977(15.2GiB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@storage252~]#ping-W1-c2192.168.152.4
PING192.168.152.4(192.168.152.4)56(84)bytesofdata.
64bytesfrom192.168.152.4:icmp_seq=1ttl=63time=0.324ms
64bytesfrom192.168.152.4:icmp_seq=2ttl=63time=0.349ms
---192.168.152.4pingstatistics---
2packetstransmitted,2received,0%packetloss,time1000ms
rttmin/avg/max/mdev=0.324/0.336/0.349/0.022ms
[root@storage252~]#ping-W1-c2192.168.153.4
PING192.168.153.4(192.168.153.4)56(84)bytesofdata.
64bytesfrom192.168.153.4:icmp_seq=1ttl=63time=0.342ms
64bytesfrom192.168.153.4:icmp_seq=2ttl=63time=0.271ms
---192.168.153.4pingstatistics---
2packetstransmitted,2received,0%packetloss,time999ms
rttmin/avg/max/mdev=0.271/0.306/0.342/0.039ms
最初还必要增加一条默许网关,才干让该体系会见其他网段主机
[root@clovem~]#routeadddefaultgw192.168.153.1
能够依据必要将静态路由下令增加至相干设置文件,重启以后仍旧失效。
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们! |
|