1

I have a scenario in which one computer needs to be a member of two subnets on the same physical network - 192.168.2.0/24 and 192.168.3.0/24. I have achieved this using ifconfig eth0:1 192.168.3.123/24 up etc. The problem arises when I am trying to start a telnet session with another host, which is also a member of those two subnets. That host is accessible via telnet on both IP addresses, but when I try to connect to it, telnet hangs. This problem disappears when I remove either one of the two interfaces. I think it is also worth mentioning that there is no problem in Windows, with the same multiple IP setup. Since the host I am trying to connect to cannot be configured or modified, is it possible to solve this problem, say, by restricting 192.168.3.0 traffic only to eth0:1, or, perhaps having a different MAC address on that pseudo interface?

  • What distribution and version are you using? – Larssend Nov 19 '15 at 3:00
  • 1
    Does telnet hang no matter which IP address you try to connect on? – Spiff Nov 19 '15 at 3:53
0

It sounds to me like a problem with the source IP address. I imagine there are multiple ways to fix this. Possibly the easiest would be to disable reverse path filtering.

An alternative option may be to rewrite packets to ensure the leaving address always matches the subnet with a couple of snat rules - possibly something like

iptables -t nat -A POSTROUTING -s 192.168.2.x -o 192.168.3.123 --sport 25
-j SNAT --to 192.168.3.x
| improve this answer | |
0

If your aliased address is used only for telnetting into this server, then there is a very simple solution: tell telnet to bind to the specific address you want to use, as in:

  telnet -b 192.168.3.123   192.168.3.201
  telnet -b 192.168.2.123   192.168.2.201

having assumed that your pc has addresses 192.168.3.123/192.168.2.123 and the remote server has IP addresses 192.168.3.201/192.168.2.201. Notice that it is necessary for the source and destination addresses to belong to the same subnet, since you did not specify the existence of a network gateway.

If instead your use of the aliased address is more general (for instance, if you receive telnet calls, in which case you cannot specify the -b option as above), then you will need to learn about policy routing. But I guess we will cross that bridge when we get there.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.