-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add EoIP tunnel support (#283)
- Loading branch information
Showing
9 changed files
with
343 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# routeros_interface_eoip (Resource) | ||
|
||
|
||
## Example Usage | ||
```terraform | ||
resource "routeros_interface_eoip" "eoip_tunnel1" { | ||
name = "eoip-tunnel1" | ||
local_address = "192.168.88.1" | ||
remote_address = "192.168.88.2" | ||
disabled = true | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) Changing the name of this resource will force it to be recreated. | ||
> The links of other configuration properties to this resource may be lost! | ||
> Changing the name of the resource outside of a Terraform will result in a loss of control integrity for that resource! | ||
|
||
### Optional | ||
|
||
- `allow_fast_path` (Boolean) Whether to allow FastPath processing. Must be disabled if IPsec tunneling is used. | ||
- `arp` (String) Address Resolution Protocol mode: | ||
* disabled - the interface will not use ARP | ||
* enabled - the interface will use ARP | ||
* local-proxy-arp - the router performs proxy ARP on the interface and sends replies to the same interface | ||
* proxy-arp - the router performs proxy ARP on the interface and sends replies to other interfaces | ||
* reply-only - the interface will only reply to requests originated from matching IP address/MAC address combinations which are entered as static entries in the ARP table. No dynamic entries will be automatically stored in the ARP table. Therefore for communications to be successful, a valid static entry must already exist. | ||
- `arp_timeout` (String) ARP timeout is time how long ARP record is kept in ARP table after no packets are received from IP. Value auto equals to the value of arp-timeout in IP/Settings, default is 30s. Can use postfix ms, s, M, h, d for milliseconds, seconds, minutes, hours or days. If no postfix is set then seconds (s) is used. | ||
- `clamp_tcp_mss` (Boolean) Controls whether to change MSS size for received TCP SYN packets. When enabled, a router will change the MSS size for received TCP SYN packets if the current MSS size exceeds the tunnel interface MTU (taking into account the TCP/IP overhead). The received encapsulated packet will still contain the original MSS, and only after decapsulation the MSS is changed. | ||
- `comment` (String) | ||
- `disabled` (Boolean) | ||
- `dont_fragment` (String) | ||
- `dscp` (String) Set dscp value in GRE header to a fixed value '0..63' or 'inherit' from dscp value taken from tunnelled traffic. | ||
- `ipsec_secret` (String, Sensitive) When secret is specified, router adds dynamic IPsec peer to remote-address with pre-shared key and policy (by default phase2 uses sha1/aes128cbc). | ||
- `keepalive` (String) Tunnel keepalive parameter sets the time interval in which the tunnel running flag will remain even if the remote end of tunnel goes down. If configured time,retries fail, interface running flag is removed. Parameters are written in following format: KeepaliveInterval,KeepaliveRetries where KeepaliveInterval is time interval and KeepaliveRetries - number of retry attempts. KeepaliveInterval is integer 0..4294967295 | ||
- `local_address` (String) Source address of the tunnel packets, local on the router. | ||
- `loop_protect` (String) | ||
- `loop_protect_disable_time` (String) | ||
- `loop_protect_send_interval` (String) | ||
- `mtu` (String) Layer3 Maximum transmission unit ('auto', 0 .. 65535) | ||
- `remote_address` (String) IP address of the remote end of the tunnel. | ||
- `tunnel_id` (String) Unique tunnel identifier, which must match the other side of the tunnel. | ||
|
||
### Read-Only | ||
|
||
- `actual_mtu` (Number) | ||
- `id` (String) The ID of this resource. | ||
- `l2mtu` (Number) Layer2 Maximum transmission unit. [See](https://wiki.mikrotik.com/wiki/Maximum_Transmission_Unit_on_RouterBoards). | ||
- `loop_protect_status` (String) | ||
- `mac_address` (String) Current mac address. | ||
- `running` (Boolean) | ||
|
||
## Import | ||
Import is supported using the following syntax: | ||
```shell | ||
# Import with the name of the EoIP interface in case of the example, use `eoip-tunnel1` | ||
terraform import routeros_interface_eoip.eoip_tunnel1 eoip-tunnel1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Import with the name of the EoIP interface in case of the example, use `eoip-tunnel1` | ||
terraform import routeros_interface_eoip.eoip_tunnel1 eoip-tunnel1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resource "routeros_interface_eoip" "eoip_tunnel1" { | ||
name = "eoip-tunnel1" | ||
local_address = "192.168.88.1" | ||
remote_address = "192.168.88.2" | ||
disabled = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
// https://help.mikrotik.com/docs/display/ROS/EoIP | ||
func ResourceInterfaceEoip() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/interface/eoip"), | ||
MetaId: PropId(Name), | ||
|
||
KeyActualMtu: PropActualMtuRo, | ||
KeyArp: PropArpRw, | ||
KeyArpTimeout: PropArpTimeoutRw, | ||
KeyAllowFastPath: PropAllowFastPathRw, | ||
KeyClampTcpMss: PropClampTcpMssRw, | ||
KeyComment: PropCommentRw, | ||
KeyDisabled: PropDisabledRw, | ||
KeyDontFragment: PropDontFragmentRw, | ||
KeyDscp: PropDscpRw, | ||
KeyIpsecSecret: PropIpsecSecretRw, | ||
KeyKeepalive: PropKeepaliveRw, | ||
KeyL2Mtu: PropL2MtuRo, | ||
KeyLocalAddress: PropLocalAddressRw, | ||
KeyLoopProtect: PropLoopProtectRw, | ||
KeyLoopProtectDisableTime: PropLoopProtectDisableTimeRw, | ||
KeyLoopProtectSendInterval: PropLoopProtectSendIntervalRw, | ||
KeyLoopProtectStatus: PropLoopProtectStatusRo, | ||
KeyMacAddress: PropMacAddressRo, | ||
KeyMtu: PropMtuRw(), | ||
KeyName: PropNameForceNewRw, | ||
KeyRemoteAddress: PropRemoteAddressRw, | ||
KeyRunning: PropRunningRo, | ||
"tunnel_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: "0", | ||
Description: "Unique tunnel identifier, which must match the other side of the tunnel.", | ||
}, | ||
} | ||
|
||
return &schema.Resource{ | ||
CreateContext: DefaultValidateCreate(resSchema, func(d *schema.ResourceData) diag.Diagnostics { | ||
if d.Get("allow_fast_path").(bool) && d.Get("ipsec_secret").(string) != "" { | ||
return diag.Errorf("can't enable fastpath together with ipsec") | ||
} | ||
return nil | ||
}), | ||
ReadContext: DefaultRead(resSchema), | ||
UpdateContext: DefaultValidateUpdate(resSchema, func(d *schema.ResourceData) diag.Diagnostics { | ||
if d.Get("allow_fast_path").(bool) && d.Get("ipsec_secret").(string) != "" { | ||
return diag.Errorf("can't enable fastpath together with ipsec") | ||
} | ||
return nil | ||
}), | ||
DeleteContext: DefaultDelete(resSchema), | ||
|
||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
|
||
Schema: resSchema, | ||
} | ||
} |
Oops, something went wrong.