I have this situation: a piece of software got hardcoded IP address (let assume it is being 22.214.171.124:20000) to which it binds a socket and sends TCP and UDP traffic to 126.96.36.199:20000 (hardcoded too). Problem is that for system to work there should be several instances of this software on separate different hosts. There is no chance to modify the software.
original setup was involving some kind of non-RFC compatible network hardware that was mapping MACs in first LAN into MACs in second LAN. Now it is required to emulate it without any extra network hardware - just a hot per instance of client and a host for server. There is (new) server software that expect to accept packets and respond, using separate NIC for each instance, IP addresses allowed to be in arbitrary subnets.
I do not see any problem with the server part, but there is now way that hosts with same IPs can be connected to server. I assume there is no problem with using system software to resolve it, but I don't know how to emulate an interface with required IP on client host and redirect traffic to server, to send traffic from server to client software (which would expect it coming from non-existing 188.8.131.52). I was told that it is possible with iptables, but all I know about that iptables is packet filter\NAT software. I may doubt that suggestion, because one who told me so knows even less than me. I have partial solution, without DMZ and redirection of traffic to proper ip
ip netns add vn ip link add v-eth0 type veth peer name v-local ip link set v-local netns vn ip addr add 184.108.40.206/24 dev v-eth0 ip netns exec vn ip addr add 220.127.116.11/24 dev v-local ip link set v-eth0 up ip netns exec vn ip link set v-local up ip netns exec vn ip route add default via 18.104.22.168 echo 1 > /sys/net/ipv4/ip_forward iptables -P FORWARD DROP iptables -F FORWARD iptables -t nat -F iptables -t nat -A POSTROUTING -s 22.214.171.124/255.255.255.0 -o eth0 -j MASQUERADE iptables -A FORWARD -i eth0 -o v-eth0 -j ACCEPT iptables -A FORWARD -o eth0 -i v-eth0 -j ACCEPT
This setup allows process in namespace container to access real network, but doesn't allow redirectio I require. Let assume that eth0 got IP 126.96.36.199 and server got IP 188.8.131.52. How I should modify the script above to be able
1) to redirect packets from 184.108.40.206 destinated to 220.127.116.11, so they would be sent to 18.104.22.168, and
2) to redirect packets, received by 22.214.171.124, to be sent to 10.10.10.100?