Community discussions

MikroTik App
 
bigsrlcuneo
just joined
Topic Author
Posts: 7
Joined: Mon Sep 11, 2023 5:58 pm

Mutliple IP on same interface

Wed Apr 17, 2024 4:37 pm

Hi Everyone
I have a doubt: if I assign a static IP to an interface, i.e.
add address=192.168.1.1/24 interface=bridge1

Then I add another static IP to the same interface
add address=192.168.1.254/24 interface=bridge1

The question is: which IP address will be used from RouteOS when its generate some packet? i.e. if router would start a telnet connection to a client, how can I chooce which IP use to start the connection?
I assume that the routes (which are dynamically created by the router) are responsible for establishing all of this when an address is added to an interface; however, I cannot modify or delete those routes.
I'm asking this because we have a lot of installations with an static IP on an interface and an DHCP client running on the same interface (due to avoid an main router switch or reset) so the RB have 2 IP but only one could be configured as DMZ in the main router so we have a little bit of confusion in how manage multiple IP.
Can someone please help me in understanding this kind of situation? I searched in documentation and online but nothig found about..

Thanks
 
User avatar
vingjfg
Member
Member
Posts: 343
Joined: Fri Oct 20, 2023 1:45 pm

Re: Mutliple IP on same interface

Wed Apr 17, 2024 4:51 pm

The following command should give you the information as local-address
/ip/route/print detail where dst-address=192.168.1.0/24

Flags: D - dynamic; X - disabled, I - inactive, A - active; 
c - connect, s - static, r - rip, b - bgp, o - ospf, i - is-is, d - dhcp, v - vpn, m - modem, y - bgp-mpls-vpn; 
H - hw-offloaded; + - ecmp 
   DAc   dst-address=192.168.1.0/24 routing-table=main gateway=vlan.10 immediate-gw=vlan.10 distance=0 scope=10 
         suppress-hw-offload=no local-address=192.168.1.1%vlan.10 

 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3591
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Mutliple IP on same interface

Wed Apr 17, 2024 5:12 pm

Assuming it's V7. The address used for "local out" traffic (e.g. telnet from router) should be shown a local-address in /ip/route/print...

To set it for traffic originated from the router (e.g. /tool/fetch, /system/ssh, telnet out, etc.), then pref-src= can be used to control. If pref-src not set on route, and multiple IPs assigned on same out-interface used, I think it just uses the first added (but not 100%) as src-address for "local out" traffic**. But the "local-address" from /ip/route would tell you for sure.

Now if it's forward traffic through a NAT, pref-src isn't used in that case (and ignored) so need to use src-nat rule to control which IP is used.


** The docs are unclear on the selection logic. For V7, they say:
The preferred source is not used anymore for connected routes. FIB chooses the source address based on the out-interface.
But don't specify the FIB's logic, and for routing/firewall pref-src is NOT used. But outbound traffic originated on router with multihoming on same subnet, pref-src= is used in that case.
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1508
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: Mutliple IP on same interface

Wed Apr 17, 2024 5:35 pm

It's been several years since I did this and it was ROS 6 something. My DSL gave me up to eight static IP addresses. I had each local LAN use a different public IP. As I recall, I just had to specify the Preferred source in the IP > Routes table. I don't THINK I had to do anything else - but as I said, it's been years so I may not be remembering it right.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3591
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Mutliple IP on same interface

Wed Apr 17, 2024 6:21 pm

Yeah in V6, pref-src is used for everything in routing. In V7, it's ONLY used for router initiated traffic.

RouterOS V7's "FIB logic" when multiple IPs in same subnet... IDK for sure. I'm don't think it's documented what happens.

I do know pref-src= on a router in V7 works for something like telnet out from router to control what is used. And the selected one is the local-address in /ip/route/print detail.
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1508
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: Mutliple IP on same interface

Wed Apr 17, 2024 6:42 pm

I have not played with ROS 7 yet except my old RB750Gr3 router that's sole purpose will be to provide a WireGuard VPN (have not tried that) so I can learn how to set up WireGuard.
My primary RB4011 router that does everything is still 6.49.8.

One of these days...

Who is online

Users browsing this forum: Bing [Bot], jaclaz and 29 guests