12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/bin/sh
- source /jffs/scripts/aiop/aiop-func
- if [ `cat ${DNSMASQ_CONF} | grep -c "log-dhcp"` -eq 0 ]; then
- pc_append "log-dhcp" ${DNSMASQ_CONF}
- fi
- assign_ip () {
- if [ $# -ne 4 ]; then
- echo "Wrong number of parameters"
- return
- fi
- IFACE="${1}"
- IFACE_INET_ADDR="${2}"
- IFACE_NWRK_ADDR="${IFACE_INET_ADDR%.*}.0"
- IFACE_MASK_ADDR="255.255.255.0"
- DHCP_START="${IFACE_INET_ADDR%.*}.${3}"
- DHCP_END="${IFACE_INET_ADDR%.*}.${4}"
- if [ `ifconfig ${IFACE} 2&> /dev/null | grep -ice "UP"` -ne 1 ]; then
- logger "dnsmasq-dhcp: Unknown interface ${IFACE}."
- return
- fi
- if [ `ifconfig | grep -ice $(_quote ${IFACE_INET_ADDR%.*}.)` -ne 0 ]; then
- if [ `ifconfig ${IFACE} | grep -ice "$(_quote ${IFACE_INET_ADDR%.*}.)"` -ne 1 ]; then
- logger "dnsmasq-dhcp: Service already running on subnet ${IFACE_INET_ADDR%.*}"
- return
- fi
- fi
- logger "dnsmasq-dhcp: Configure ${IFACE} to have special DHCP on ${IFACE_INET_ADDR}"
-
- if [ `cat ${DNSMASQ_CONF} | grep -c ${IFACE}` -eq 0 ]; then
- cmd_run "pc_append" "pc_append interface=${IFACE} ${DNSMASQ_CONF}"
- cmd_run "pc_append" "pc_append dhcp-range=${IFACE},${DHCP_START},${DHCP_END},${IFACE_MASK_ADDR},24h ${DNSMASQ_CONF}"
- cmd_run "pc_append" "pc_append dhcp-option=${IFACE},3,${IFACE_INET_ADDR} ${DNSMASQ_CONF}"
- fi
- cmd_run "ifconfig" "ifconfig ${IFACE} ${IFACE_INET_ADDR} netmask ${IFACE_MASK_ADDR}"
- ebtable "${IFACE}" "I" "ipv4"
- ebtable "${IFACE}" "I" "ipv6"
- ebtable "${IFACE}" "I" "arp"
- iptable "${IFACE}" "I" "INPUT" "ACCEPT"
- }
|