Configure DHCP file in /etc/config/dhcp

829 views
Skip to first unread message

Vo Duy Hieu

unread,
May 12, 2017, 8:12:06 AM5/12/17
to OpenWISP
Hi, 
I'm newbie in OpenWiSP. After following some guides (how to install OpenWiSP on Raspberry Pi 3 and install Openwisp-config on OpenWRT devices), now my OpenWRT devices are totally controlled by Raspberry.
After that, I started to configure wireless access point on my OpenWRT. Everything seemed to be OK (I could receive my Wifi Signal). But when I connected to this Wifi, I couldn't receive IP Address. Looking at interface I had created, I figured that it didn't configure DHCP Server on this interface (that's why I coudn't receive IP Address).
And how can I configure this section on OpenWiSP, or I must create it directly on OpenWRT devices?

Thanks in advance!
If you need to provide more information, please let me know.
Here's some pictures and my template configuration:



package network

config interface 'wlan0'
	option ifname 'wlan0'
	option proto 'none'

config interface 'wlan0'
	option ifname 'wlan0 eth1.1'
	option ipaddr '10.0.0.1'
	option netmask '255.192.0.0'
	option proto 'static'
	option type 'bridge'

package wireless

config wifi-device 'radio0'
	option channel '11'
	option country 'VN'
	option disabled '0'
	option htmode 'HT20'
	option hwmode '11g'
	option txpower '18'
	option type 'mac80211'

config wifi-iface 'wifi_wlan0'
	option device 'radio0'
	option encryption 'psk2+tkip+ccmp'
	option ifname 'wlan0'
	option isolate '1'
	option key 'a1b22c333'
	option mode 'ap'
	option ssid 'OpenWiSP'

Federico Capoano

unread,
May 12, 2017, 9:41:19 AM5/12/17
to OpenWISP
Could you share the contents of /etc/config/dhcp that is present in one of your routers?

Could you also share the NetJSON configuration you have set up?

Go to advanced mode and copy the JSON data

Vo Duy Hieu

unread,
May 16, 2017, 2:52:34 AM5/16/17
to OpenWISP
Sorry for my late reply. 
Now, my clients can receive IP from OpenWRT via OpenWiSP template configuration. Here's my JSON configuration file.
{
    "radios": [
        {
            "protocol": "802.11n",
            "name": "radio0",
            "disabled": false,
            "driver": "mac80211",
            "channel_width": 20,
            "tx_power": 18,
            "channel": 11,
            "country": "VN",
            "hwmode": "11g"
        }
    ],
    "interfaces": [
        {
            "wireless": {
                "mode": "access_point",
                "radio": "radio0",
                "ssid": "OpenWiSP",
                "encryption": {
                    "protocol": "wpa2_personal",
                    "key": "a1b22c333",
                    "cipher": "tkip+ccmp"
                },
                "maxassoc": 3
            },
            "type": "wireless",
            "network": "wlan0",
            "name": "wlan0"
        },
        {
            "bridge_members": [
                "wlan0",
                "eth1.1"
            ],
            "type": "bridge",
            "addresses": [
                {
                    "proto": "static",
                    "family": "ipv4",
                    "gateway": "",
                    "mask": 10,
                    "address": "10.0.0.1"
                }
            ],
            "name": "wlan0"
        }
    ],
    "dhcp": [
        {
            "config_name": "dhcp",
            "config_value": "wlan0",
            "start": 100,
            "limit": 150,
            "leasetime": "12h",
            "interface": "wlan0"
        }
    ],
    "firewall": [
        {
            "config_name": "zone",
            "config_value": "cfg04dc81",
            "output": "ACCEPT",
            "input": "ACCEPT",
            "forward": "ACCEPT",
            "network": "lan wlan0",
            "name": "lan"
        },
        {
            "config_name": "zone",
            "config_value": "cfg06dc81",
            "name": "wan",
            "input": "ACCEPT",
            "output": "ACCEPT",
            "forward": "ACCEPT",
            "masq": 1,
            "mtu_fix": 1,
            "network": "wan wan6"
        }
    ]
}

I've just added DHCP field into JSON file, so that clients now can receive IP from OpenWRT devices.
Now, I wonder if I can get a IP from my OpenWiSP Controller (OpenWRT devices now act like a DHCP agent and OpenWiSP Controller is a DHCP Controller). Can you help me? Thanks you!

Federico Capoano

unread,
May 16, 2017, 4:11:30 AM5/16/17
to open...@googlegroups.com, Vo Duy Hieu
Hi Vo Duy Hieu,

On Tue, May 16, 2017 at 8:52 AM Vo Duy Hieu wrote:
Sorry for my late reply. 
Now, my clients can receive IP from OpenWRT via OpenWiSP template configuration. Here's my JSON configuration file.

[cut] 

I'm glad you made it. I would have done it slightly differently, but what's important is that it's working.

I've just added DHCP field into JSON file, so that clients now can receive IP from OpenWRT devices.
Now, I wonder if I can get a IP from my OpenWiSP Controller (OpenWRT devices now act like a DHCP agent and OpenWiSP Controller is a DHCP Controller). Can you help me? Thanks you!

If I understood correctly, you want a centralized DHCP server right?

In that case, you have to have all your devices and openwisp2 instance on the same layer2 network: devices and DHCP server must be on the same LAN, or wifi and LAN bridge together, or you will have to use Layer2 VPNs (eg: OpenVPN TAP) to connect different buildings.

It depends on your use case scenario, but as a general suggestion, you can use dnsmasq as a centralized DHCP server and turn off all the DHCP servers on the OpenWRT routers. If you need to use a layer2 VPN, you can use OpenVPN in bridged mode, which is supported by OpenWISP 2 (although there's not much documentation or step by step tutorial on how to set it up yet).

Federico

Vo Duy Hieu

unread,
May 17, 2017, 4:29:50 AM5/17/17
to OpenWISP
Hi Federico Capoano,
Thanks for your suggestion, I'll try using dnsmasq. But If I use dnsmasq, I have to configure on each OpenWRT devices or I can use OpenWiSP Controller to do this?

Federico Capoano

unread,
May 17, 2017, 10:56:09 AM5/17/17
to OpenWISP
You just need to use OpenWISP to create a template that creates a wifi interface which is bridged to the LAN interface (is devices are located in the same LAN) or the Layer2 VPN interface (if devices are geographically distributed across many cities).

Wifi clients will then send DHCP requests on the layer2 network which will be intercepted by the DHCP-server which will in turn send replies.

Federico
Reply all
Reply to author
Forward
0 new messages