diff --git a/shared/src/types.rs b/shared/src/types.rs index fb028a6..4950647 100644 --- a/shared/src/types.rs +++ b/shared/src/types.rs @@ -385,9 +385,9 @@ pub struct NetworkOpt { /// If not set, innernet will auto-select based on availability. pub backend: Backend, - #[structopt(long, default_value = "1420")] - /// Specify the desired MTU for your interface. - pub mtu: u32, + #[structopt(long)] + /// Specify the desired MTU for your interface (default: 1420 for IPv4 and 1400 for IPv6). + pub mtu: Option, } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] diff --git a/shared/src/wg.rs b/shared/src/wg.rs index 7a54952..40386a4 100644 --- a/shared/src/wg.rs +++ b/shared/src/wg.rs @@ -85,7 +85,7 @@ pub fn up( .set_private_key(wgctrl::Key::from_base64(&private_key).unwrap()) .apply(interface, network.backend)?; set_addr(interface, address)?; - set_up(interface, network.mtu)?; + set_up(interface, network.mtu.unwrap_or_else(|| if address.is_ipv4() { 1420 } else { 1400 }))?; if !network.no_routing { add_route(interface, address)?; }