diff --git a/gluon-upgrade-static-interface-ffhh/Makefile b/gluon-upgrade-static-interface-ffhh/Makefile new file mode 100644 index 0000000..9381891 --- /dev/null +++ b/gluon-upgrade-static-interface-ffhh/Makefile @@ -0,0 +1,36 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-upgrade-static-interface-ffhh +PKG_VERSION:=1 +PKG_RELEASE:=1 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/gluon-upgrade-static-interface-ffhh + SECTION:=gluon + CATEGORY:=Gluon + TITLE:=Configure infaces with static IP + DEPENDS:=+gluon-core +gluon-ebtables +endef + +define Package/gluon-upgrade-static-interface-ffhh/description + This package allows to define interface with static ip adresses in gluon config +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/gluon-upgrade-static-interface-ffhh/install + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,gluon-upgrade-static-interface-ffhh)) diff --git a/gluon-upgrade-static-interface-ffhh/README.md b/gluon-upgrade-static-interface-ffhh/README.md new file mode 100644 index 0000000..7956e96 --- /dev/null +++ b/gluon-upgrade-static-interface-ffhh/README.md @@ -0,0 +1,17 @@ +# ffhh gluon-upgrade-static-interface-ffhh + +This package adds options to /etc/config/gluon to configure an additional interface with static IP. +This interface can be used, for example, for local management networks or configuration interfaces of WLAN radio links. + +### Configuration + +In /etc/config/gluon several interfaces with static addresses can be created. + +```lua +config interface 'wartung' + option netmask '255.255.255.0' + option proto 'static' + option ipaddr '192.168.0.1' + option ifname 'lan1.5' +``` + diff --git a/gluon-upgrade-static-interface-ffhh/files/lib/gluon/upgrade/118-interface-static-IP b/gluon-upgrade-static-interface-ffhh/files/lib/gluon/upgrade/118-interface-static-IP new file mode 100755 index 0000000..008164f --- /dev/null +++ b/gluon-upgrade-static-interface-ffhh/files/lib/gluon/upgrade/118-interface-static-IP @@ -0,0 +1,34 @@ +#!/usr/bin/lua + +local uci=require('simple-uci').cursor() + +local function has_static_role(section) + for _, role in ipairs(section.role or {}) do + if role == "static" then + return true + end + end + return false +end + +uci:foreach('gluon', 'interface', function(s) + if has_static_role(s) then + -- io.stderr:write("+++ ") + -- io.stderr:write(s[".name"]) + -- io.stderr:write("\n") + + local config_section = { proto = "static" } + local mapping = { ipaddr = "ipaddr", ifname = "name", netmask = "netmask" } + + for key, lookup in pairs(mapping) do + local value = uci:get('gluon', s[".name"], lookup) + if value then + config_section[key] = value + end + end + + uci:section('network', 'interface', s[".name"], config_section) + end +end) + +uci:save('network') diff --git a/gluon-upgrade-static-interface-ffhh/files/lib/gluon/upgrade/340-firewall-static-interface b/gluon-upgrade-static-interface-ffhh/files/lib/gluon/upgrade/340-firewall-static-interface new file mode 100755 index 0000000..02565d6 --- /dev/null +++ b/gluon-upgrade-static-interface-ffhh/files/lib/gluon/upgrade/340-firewall-static-interface @@ -0,0 +1,27 @@ +#!/usr/bin/lua + +local uci=require('simple-uci').cursor() + +local function has_static_role(section) + for _, role in ipairs(section.role or {}) do + if role == "static" then + return true + end + end + return false +end + +uci:foreach('gluon', 'interface', function(s) + if has_static_role(s) then + + uci:section('firewall','zone',s[".name"],{ + name=s[".name"], + network=s[".name"], + input='ACCEPT', + output='ACCEPT', + forward='DROP', + }) + end +end) + +uci:save('firewall')