Linux服务器绑定多网卡IP

需求:在1台Linux上绑定两个公网IP,实现扩展IP用于专用的服务
问题:添加了一个网卡上绑定1个弹性IP,主网卡绑定的公网ip可以正常访问,但是扩展网卡的公网ip无法访问。
原因:没有设置路由规则,导致新加的扩展网卡IP无法访问
 
1:添加一个 route table 别名test
[root@test ~]# vim /etc/iproute2/rt_tables
#
# reserved values
#
255     local
254     main
253     default
0       unspec
32000  test
#
# local
#
#1      inr.ruhep
 
##添加32000  test,然后保存退出!
 
2:在test表添加一条路由
[root@test ~]# ip route add default via 172.16.0.1 dev eth1 table test
 
##172.16.0.1(扩展网卡的网关ip),test(添加test表)
 
 
3:添加策略路由
[root@test ~]# ip rule add from 172.16.0.13 lookup test prio 32000
 
##172.16.0.13(扩展网卡的私网IP)
 
4:通过Telnet+IP测试是否可以访问
[c:\~]$ telnet 139.159.236.94 22
 
 
Connecting to 139.159.236.91:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
SSH-2.0-OpenSSH_7.4
Connection closing...Socket close

猜你喜欢

转载自www.cnblogs.com/douyi/p/11583770.html