Commit 8f0c125f authored by nanahira's avatar nanahira

add direct

parent 09f822aa
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
source {{ansible_user_dir}}/nextgen-router/scripts/utility.sh source {{ansible_user_dir}}/nextgen-router/scripts/utility.sh
export BRIDGE_NAME={{br.name}} export BRIDGE_NAME={{br.name}}
{% if br.macvlan is defined and br.macvlan %} {% if br.macvlan is defined and br.macvlan and br.links is defined and br.links and br.links | length > 0 %}
# macvlans # macvlans
{% for link in br.links %} {% for link in br.links %}
......
...@@ -7,6 +7,7 @@ export BRIDGE_NAME={{br.name}} ...@@ -7,6 +7,7 @@ export BRIDGE_NAME={{br.name}}
{{br.linkUp}} {{br.linkUp}}
{% endif %} {% endif %}
{% if br.links is defined and br.links and br.links | length > 0 %}
{% for link in br.links %} {% for link in br.links %}
# link {{link}} # link {{link}}
...@@ -19,5 +20,6 @@ ip link add link {{link}} dev {{br.name}}{{link | regex_replace('\.', '')}} type ...@@ -19,5 +20,6 @@ ip link add link {{link}} dev {{br.name}}{{link | regex_replace('\.', '')}} type
ip link set {{br.name}}{{link | regex_replace('\.', '')}} up ip link set {{br.name}}{{link | regex_replace('\.', '')}} up
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %}
true true
...@@ -83,6 +83,7 @@ iface {{vlan.link}}.{{vlan.tag}} inet6 manual ...@@ -83,6 +83,7 @@ iface {{vlan.link}}.{{vlan.tag}} inet6 manual
auto {{br.name}} auto {{br.name}}
allow-hotplug {{br.name}} allow-hotplug {{br.name}}
iface {{br.name}} inet {{br.type}} iface {{br.name}} inet {{br.type}}
{% if not (br.direct is defined and br.direct) %}
{% if br.links is defined and br.links and br.links | length > 0 %} {% if br.links is defined and br.links and br.links | length > 0 %}
bridge_ports{% for link in br.links %} {% if br.macvlan is defined and br.macvlan %}{{br.name}}{{link | regex_replace('\.', '')}}{% else %}{{link}}{% endif %}{% endfor %} bridge_ports{% for link in br.links %} {% if br.macvlan is defined and br.macvlan %}{{br.name}}{{link | regex_replace('\.', '')}}{% else %}{{link}}{% endif %}{% endfor %}
...@@ -95,6 +96,7 @@ bridge_stp on ...@@ -95,6 +96,7 @@ bridge_stp on
bridge_stp off bridge_stp off
{% endif %} {% endif %}
bridge_maxwait 3 bridge_maxwait 3
{% endif %}
{% if br.type == "static" %} {% if br.type == "static" %}
address {{br.address}} address {{br.address}}
{% elif br.type == "dhcp" %} {% elif br.type == "dhcp" %}
......
#!/bin/bash #!/bin/bash
{% if not (ppp.direct is defined and ppp.direct) %}
ip link del dev pppm{{ppp.id}} ip link del dev pppm{{ppp.id}}
{% endif %}
...@@ -3,8 +3,10 @@ source {{ansible_user_dir}}/nextgen-router/scripts/utility.sh ...@@ -3,8 +3,10 @@ source {{ansible_user_dir}}/nextgen-router/scripts/utility.sh
_wait_for_interface_online {{ppp.link}} _wait_for_interface_online {{ppp.link}}
{% if not (ppp.direct is defined and ppp.direct) %}
ip link add link {{ppp.link}} dev pppm{{ppp.id}} type macvlan ip link add link {{ppp.link}} dev pppm{{ppp.id}} type macvlan
ip link set pppm{{ppp.id}} up ip link set pppm{{ppp.id}} up
{% if ppp.mac is defined and ppp.mac %} {% if ppp.mac is defined and ppp.mac %}
ip link set pppm{{ppp.id}} address {{ppp.mac}} ip link set pppm{{ppp.id}} address {{ppp.mac}}
{% endif %} {% endif %}
{% endif %}
...@@ -4,7 +4,11 @@ noauth ...@@ -4,7 +4,11 @@ noauth
persist persist
maxfail 0 maxfail 0
holdoff 5 holdoff 5
{% if ppp.direct is defined and ppp.direct %}
plugin rp-pppoe.so {{ppp.link}}
{% else %}
plugin rp-pppoe.so pppm{{ppp.id}} plugin rp-pppoe.so pppm{{ppp.id}}
{% endif %}
user "{{ppp.username}}" user "{{ppp.username}}"
ifname ppp{{ppp.id}} ifname ppp{{ppp.id}}
+ipv6 +ipv6
...@@ -23,6 +23,7 @@ vars: ...@@ -23,6 +23,7 @@ vars:
links: links:
- bond0 # 上行链路 - bond0 # 上行链路
type: static # dhcp还是static,manual理论上也可以 type: static # dhcp还是static,manual理论上也可以
direct: false # 是否不使用 bridge 直接连。这种情况下那个网卡不能在别处出现。
address: 10.0.0.1/24 # 首选地址 address: 10.0.0.1/24 # 首选地址
moreAddresses: moreAddresses:
- 10.0.0.2/24 # 备选地址 - 10.0.0.2/24 # 备选地址
...@@ -71,6 +72,7 @@ vars: ...@@ -71,6 +72,7 @@ vars:
username: user # 拨号用户名,密码在pppoeUsers给出 username: user # 拨号用户名,密码在pppoeUsers给出
mac: null # 给ISP看的mac地址,null为随机 mac: null # 给ISP看的mac地址,null为随机
dhcpv6Client: false # 使用这里的DHCPv6,所有ppp只能有1个 dhcpv6Client: false # 使用这里的DHCPv6,所有ppp只能有1个
direct: false # 是否不使用 macvlan 直接连。这种情况下同一个链路不能多次使用,且不能使用 mac 属性。
pppoeUsers: # PPPoE帐号 pppoeUsers: # PPPoE帐号
- username: user - username: user
password: pass password: pass
......
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