Community discussions

MikroTik App
 
ahmet82
newbie
Topic Author
Posts: 49
Joined: Thu Aug 20, 2020 12:26 am

translate vlan without switch chip

Sat Oct 31, 2020 5:16 pm

I have a unifi access point. I connect to a tplink switch and assigned a port based vlan id. My mikrotik router assigns the correct ip via dhcp server that is targeting the vlan. So all it good here.

The access point has a port that i connected another device via ethernet. The switch naturally assigns the same vlan with access point based on the port. However for this device, i want to use another vlan and thereforw another ip block with another dhcp.

I read that vlan id is possible via switch chip. I have an hex s. I dont think it supports this feature. I get an error when i try. How is this achiavle from only software side?
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: translate vlan without switch chip

Sat Oct 31, 2020 5:43 pm

Sure. Everything about VLAN handling on bridges is here. If the Ethernet interface, to which the TP-link is connected, is not a member port of a bridge, you can attach an /interface vlan directly to that Ethernet port.
 
ahmet82
newbie
Topic Author
Posts: 49
Joined: Thu Aug 20, 2020 12:26 am

Re: translate vlan without switch chip

Sat Oct 31, 2020 5:53 pm

Not sure how it would work though.

Tplink assigns a vlan id to incoming packet
Send it to mikrotik through trunk port
Router receives same vlan id for both access point and the new device

How can i make it differ by mac address?
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: translate vlan without switch chip

Sat Oct 31, 2020 6:21 pm

Ah, sorry, I didn't get properly your OP as I couldn't understand the application case. Is the other VLAN connected to some other interface of the Mikrotik so that you would like that device to talk to other devices in that VLAN? There is currently no way to change a VLAN ID in software. So you can only use the MAC address to choose a static DHCP lease if that helps.
 
ahmet82
newbie
Topic Author
Posts: 49
Joined: Thu Aug 20, 2020 12:26 am

Re: translate vlan without switch chip

Sat Oct 31, 2020 6:31 pm

I tried to assign static ip via dhcp lease settings.

I entered the mac id, entered static ip, selected dhcp server that i originally preffered(if the vlan was correct), nothing got assigned

Esentially i am fine if i can assign the correct static ip to the new device, but for some reason, i think because vlans dont match with the dhcp server vlan, static ip doesnt work
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: translate vlan without switch chip

Sat Oct 31, 2020 7:07 pm

I tried to assign static ip via dhcp lease settings.

I entered the mac id, entered static ip, selected dhcp server that i originally preffered(if the vlan was correct), nothing got assigned

Esentially i am fine if i can assign the correct static ip to the new device, but for some reason, i think because vlans dont match with the dhcp server vlan, static ip doesnt work
I am lost again. You said that the VLAN ID is the same for the packets from the AP itself and for the packets from that "other device", so they land on the same /interface vlan in Mikrotik.

For DHCP, some devices use client-id built from their MAC address and some build it from different property of theirs (like serial number). So the easiest way is not to prepare the lease in advance, but to let the device get an automatically generated lease, and then use /ip dhcp-server lease make-static to convert it to a manual one, and change the address value in the manual one to what you need; it may even not be a single address, you can use a pool name as address

But the lease must stay linked to the server which listens on the DHCP server bound to that /interface vlan through which the device is connected, and if packets should reach that device via that interface, you have to either add the corresponding subnet to that interface (which you can only do if the same subnet is not attached to another one), or you must add a route with the device's IP address as dst-address and the /interface vlan as gateway. Plus in order that the device was able to send data, it needs to be able to resolve the address of the gateway using ARP, so you'd need some bridge nat rules.. so a /30 subnet attached to the /interface vlan and a corresponding /ip dhcp-server network profile are probably a better way of dealing with it.

To get a better answer, you have to describe the complete use case (if you plan to assign an IP address from some subnet to that specfic device, what else is connected to that subnet and how).

However, I'd assume it to be much easier to permit VLAN tagging on the Unifi? The "other device" is connected to one Ethernet port of the AP, the TPlink to the other one. The management of Unifi is in VLAN A, the wireless interface is in VLAN B, the TP-link tags/untags VLAN C and lets A and B through transparently. Unifi forwards tagless packets between the ports.
 
ahmet82
newbie
Topic Author
Posts: 49
Joined: Thu Aug 20, 2020 12:26 am

Re: translate vlan without switch chip

Sat Oct 31, 2020 8:09 pm

Let's ignore VLANs for now, as I'm unable to do it with that approach.

Let's say I have 2 dhcp servers.

dhcp server 1 with 10.1.2.0/24
dhcp server 2 with 10.1.3.0/24

The VLAN ID that the new device is connecting to is attached to dhcp server 1. So it gets the ip, and everything is working.

However, I want to create an exception rule for the mac address so that the device gets ip from dhcp server 2.

It feels like If I just enter 10.1.3.20 as the static ip, and keep selecting dhcp server 1, it doesn't work. this one ip is bounded, but device is unreacable.
If I set the dhcp server 2 as the dhcp server, it doesn't work. this one doesn't bound any ip.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19352
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: translate vlan without switch chip

Sat Oct 31, 2020 8:37 pm

Without a well labelled network diagram all the text in the world may not help.
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: translate vlan without switch chip

Sat Oct 31, 2020 8:57 pm

The point is that it is not enough that the "new device" (ND) would just get an IP address from 10.1.3.0/24 - say, 10.1.3.22. It is also necessary that packets from other devices in 10.1.3.0/24 could reach it. And as the ND and the other devices in the 10.1.3.0/24 range are in different VLANs, the traffic between them has to be routed, not bridged.

So you have to dedicate a whole "sub-subnet" of 10.1.3.0/24 for the ND, let' say 10.1.3.20/30. Then, 10.1.3.1/24 stays attached to the interface to which DHCP server 2 is attached, and 10.1.3.21/30 will be attached to the interface to which DHCP server 1 is attached, simultaneously with its "primary" address 10.1.2.1/24. The /ip dhcp-server network row for address=10.2.3.20/30 will indicate 10.2.3.21 as default-gateway and dns-server. And the static lease for 10.2.3.22 must be attached to DHCP server 1 too. The addresses occupied by 10.22.3.20/30 must not be available in the pool used by DHCP server 2 for assignment.

In order that the other devices in 10.2.3.0/24 would send packets for the ND (10.2.3.22) to the router's MAC address, so that the router could deliver them to the ND, the router must respond with its own MAC address to ARP requests coming to the interface to which DHCP server 2 is attached. You can do that by setting arp=proxy-arp on that interface, but I'd rather recommend to use a more selective approach. Assuming that DHCP server 2 is attached to ether2, you use the following command:
ip arp add address=10.2.3.22 mac-address=[/interface ethernet get ether2 mac-address] published=yes interface=ether2

Who is online

Users browsing this forum: ips, oquiroz, stef70 and 140 guests