Commit 7df343d3 authored by nanahira's avatar nanahira

allow using first or last available address as gateway

parent 71b94c9e
......@@ -25,6 +25,13 @@ handle_gateway() {
GATEWAY_ADDRESS=$2
GATEWAY_MAC=$3
GATEWAY_NEXT_HOP_MARK=$[$GATEWAY_ID + 1100]
BRIDGE_IP=$(ip -4 addr show dev "$BRIDGE_NAME" | grep 'inet ' | awk '{print $2}')
if [[ "$GATEWAY_ADDRESS" -eq "_use_first" ]]; then
GATEWAY_ADDRESS=$(subnetcalc "$BRIDGE_IP" -n | grep "Host Range" | awk '{print $5}')
fi
if [[ "$GATEWAY_ADDRESS" -eq "_use_last" ]]; then
GATEWAY_ADDRESS=$(subnetcalc "$BRIDGE_IP" -n | grep "Host Range" | awk '{print $7}')
fi
ip route add default via "$GATEWAY_ADDRESS" table "$GATEWAY_NEXT_HOP_MARK"
ip route add default via "$GATEWAY_ADDRESS" metric "$GATEWAY_NEXT_HOP_MARK"
ip rule add pref 100 fwmark "$GATEWAY_NEXT_HOP_MARK" lookup "$GATEWAY_NEXT_HOP_MARK"
......
......@@ -24,14 +24,3 @@ services:
RRTYPE: A
{% endif %}
{% endfor %}
{% for instance in services.tr069 %}
tr069-daemon-{{instance.interface}}:
restart: always
image: git-registry.mycard.moe/nanahira/tr069-daemon
network_mode: host
cap_add:
- NET_ADMIN
environment:
TRO69_INTERFACE: {{instance.interface}}
TABLE: {{instance.table}}
{% endfor %}
......@@ -10,7 +10,7 @@
tasks:
- name: apt
apt:
name: net-tools,bridge-utils,ifenslave,vlan,pppoe,iproute2,iptables,ipset
name: net-tools,bridge-utils,ifenslave,vlan,pppoe,iproute2,iptables,ipset,subnetcalc
update_cache: true
- name: Ubuntu things
apt:
......
......@@ -75,9 +75,6 @@ vars:
- 114.114.114.114
- 223.5.5.5
services:
tr069:
- interface: brtr069 # tr069 网卡名
table: 305 # tr069 路由表id
ddns:
- name: test-ddns
email: name@example.com # cf邮箱
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment