Why ?
I want to use OpenWRT on Orange Pi Zero, but OPiZ only have one ethernet port. So, how i can use that single port as dhcp server (to give internet), and dhcp client (to get internet).
Contents
Mikrotik Setting
Configure DHCP Server and vlan interface
-
Configure MIkrotik DHCP server as usual, for this notes sake, I configure dhcp server as :
interface : ether2
ip > addresses : 192.168.88.1/24
ip > fi > nat masquarade ether2
ip > route > dst-address = 192.168.88.0/24 gateway=ether2 -
Add vlan on interface, on some article ,vlan naming convention use ip third subnet as name, In this case, Mikrotik dhcp server ip is
192.168.[88].1
so vlan id is88
/interface vlan add name=vlan-88 interface=ether2 vlan-id=88
Configure DHCP Client
- Configure mikrotik to accept lease ip from openwrt,
Interface : ether2
ip > addresses : 10.5.51.254 network 10.5.51.1 (ip dhcp server openwrt)
ip > route > dst-address=10.5.51.1 gateway=ether2
ip > route > dst-address=10.5.51.0/24 gateway=10.5.51.1 (to be able to ping from local)
OpenWRT Setting
DHCP Server
default dhcp server setting on lan or bridge interface should works, on this case I set bridge-lan interface using ip 10.5.51.1/24
VLAN DHCP CLient
CLI version source Openwrt DOCs
Add Virtual Device
notes below are using LUCI.
- Network > interfaces > devices > add new
device type choosevlan (802.1q)
- base device use
eth0
(or any physical eth on device) - Vlan id
88
(as per this notes) - device name
eth0.88
(or any of your choices)
Add Virtual Interface
- Network > interfaces > interfaces > add new
- Name
VLAN88
(or any of your choices) - Protocol
DHCP Static
- Device :
eth0.88
Save and restart openwrt device.
Common Problem
- cant ping if using unmanaged switch, this is because unmanaged switch usually only has 1500 MTU, and VLAN add 4 more byte to 1504 making random error.