现在有ipA: 123.123.123.1 ipB: 123.123.123.2 网关:123.123.123.100
ipA上绑定了apache,ipB上绑定了另外一java程序
网络配置
iface eth0:1 inet static
address 123.123.123.1
netmask 255.255.255.0
gateway 123.123.123.100
iface eth0:2 inet static
address 123.123.123.2
netmask 255.255.255.0
现在数据从ipA进来后正常,但是从ipB进来的数据也默认标识成ipA出去了,导致原来用ipB访问的用户收不到数据
为了临时解决问题就接上第二个网卡的网线,将第二个网卡设成ipB,然后输入以下命令
ip ro add 123.123.123.100 dev eth1 src 123.123.123.2 table 100
ip ro add default dev eth1 table 100
ip ru add from 123.123.123.2 table 100
两服务就都能正常访问了,但这解决方法太菜了,不知道正确的做法应该是怎样的呢?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你确定你网络配置没有问题吗?正常情况下一个包进出肯定不会被改掉src ip的,没有iptables之类的配置吗?