0

I have a question about routing. I've searched the Internet, found some hints but couldn't make it work.

I have a server with 2 public IP and the same gateway. Let's say 1.1.1.1 (on eth0) and 1.1.1.2 (on eth0:0) and gateway is 1.1.1.254 (network /24).

There is a second server (not mine) with IP 2.2.2.2/24.

Between those 2 servers, I have radius and http flux.

Right now all the flux from my server to the other server originates from the IP 1.1.1.1. Please also note that Radius listen on IP 1.1.1.2 and port 1812 and 1813 (both UDP).

What I want to do is that only the packet originating from Radius ports are sent with source IP 1.1.1.2. All HTTP traffic must originates from 1.1.1.1 as before.

2 Answers 2

1

Just ask your radius server to bind to 1.1.1.2 only. That way it will only communicate with IP 1.1.1.2. That's exactly why bind() is designed for.

Note that on Linux, bind() does not restrict which network interface can be used to communicate. It just restricts what IP address can be used.

Of course, if a client connects to 1.1.1.1 anyway, it will be rejected. But this communication cannot work anyway: If you reply as 1.1.1.2 anyway, the host that contacted 1.1.1.1 will not recognise that the two IP belong to the same host.


Also your post suggest that you are using ifconfig and interface aliases. Please note that ifconfig is obsolete and interface aliases are seriously deprecated. The kernel have the native functionality to add several IP address to an interface since ages, and this interface alias thing is just a compatibility layer for old applications like ifconfig. Please use ip from the iproute2 package. ìp addr and ip route will show you the true configuration of your network interfaces.

2
  • Right now Radius already listen only on the desired IP (1.1.1.2). However it seems that the packets sent by my server arrives on the other server with the wrong IP (1.1.1.1). Which looks weird, I agree.
    – Bob
    Nov 6, 2013 at 10:14
  • If your server sends packets with the correct source address (verified via tcpdump/*shark, i presume) but your other server receives them with a wrong IP, then there is something in the middle that modifies it, and your server cannot do anything about it.
    – BatchyX
    Nov 6, 2013 at 10:20
0

If you have primary and secondary IPs on an interface, connections originating from that machine use the primary IP by default. I don't think you can change that easily.

3
  • Thanks for the answer. Actually, I did edit my first post. It wasn't clear enough. There is one IP on eth0 (the current default IP) and a second one on eth0:0.
    – Bob
    Nov 6, 2013 at 9:23
  • Yeah, it's as I described, a secondary address.
    – Marki
    Nov 6, 2013 at 9:25
  • OK, "unfortunately" you understood correctly my problem :) Thanks a lot for your time.
    – Bob
    Nov 6, 2013 at 9:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .