[SOLVED but not really] DCHP Fallback IP

Issue 1: I have a device (Mikrotik mAP-2nD) that has two ports. I want the second port (labeled ETH2, but internally eth0.2 based on switch0 vlan2) to behave as a dhcp client, but if no dhcp server present, will default to a static ip address.

Issue 2: This is related in that I have tested functionality of port as dhcp client and all works as expected. If however I set that port to have a static address, I lose functionality on that port (can't ping it or access GUI). Not sure what is causing this.

Both items are related in that if Issue 1 is resolved and I can get it to default to a static ip, then I may lose all functionality as mentioned in issue 2.

Any help would be appreciated.

  • Are you aware VLAN 1 and 2 are setup by default in OpenWrt, as LAN and WAN respectively?
  • Did you change those settings?
  • I assume you're trying to make a LAN?
  • Did you allow access to the GUI by firewall?
  • Can you post your /etc/config/network file?

Wow, thanks for the fast response.
A little more information before answering your questions:
I am connecting a PLC( to port 1( (as a MODBUS slave). I want to use port 2 to connect either a PC or an HMI (touchscreen). In the case of a PC, I want port 2 to either be dhcp client or fixed address (depending on situation) and will forward all port502 traffic on to PLC( In the case of connecting HMI, I would need port 2 to be the same IP address as the PLC as the HMI is hard-coded to send to specific IP. I would then need to forward that on to the PLC. I have no idea on how to accomplish the HMI portion as that would mean 2 devices with the same IP address which doesn't work (unless you have some ideas like maybe forwarding from specific IP address in that the HMI will always have IP

  1. I am aware of that. I played with that for a bit.
  2. I did not change those settings (I did, but changed them back)
  3. My use case is a bit strange, I am using the device more as a gateway to a PLC that is connected to eth0.1 (ETH1 by their label). In reality I don't care about WAN/LAN etc. as these devices will be used in specific situations.
  4. I have tried to open any and all firewall settings for testing purposes, but I will admit that my expertise with firewall and switch settings is not great.
  5. See below. the 'wwan' is wireless on wlan0 and all works fine on that end of things. I can control the PLC through that IP whether it is set as AP MASTER or if it is joined to another network.
config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr ''
	option netmask ''

config globals 'globals'
	option ula_prefix 'fddb:975e:5252::/48'

config interface 'wan'
	option ifname 'eth0.2'
	option proto 'dhcp'

config interface 'lan'
	option ifname 'eth0.1'
	option proto 'static'
	option netmask ''
	option ipaddr ''
config interface 'wwan'
	option proto 'dhcp'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option vid '1'
	option ports '0t 1'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option vid '2'
	option ports '0t 2'

I was able to achieve my goal by simply disabling VLAN functionality and then creating two interfaces on eth0 (the switch). One for DHCP and one static and then some port forwarding rules. I'm good to go. Wanted to keep some additional separation in there with the VLANs, but is isn't a must. I'll mark this as solved, but only in terms of my particular use case.

Correct, as what you did can cause issues in most other common use cases.

Glad you got it working.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.