Created
January 8, 2020 19:04
-
-
Save snowmerak/285a02aea43ba4e8fcafe6deb741eb87 to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"fmt" | |
"net" | |
"os" | |
"os/exec" | |
) | |
func main() { | |
netInterfaces, err := net.Interfaces() | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
var mtu string | |
if len(os.Args) < 2 || os.Args[1] != "on" { | |
mtu = "1500" | |
} else { | |
mtu = "400" | |
} | |
for _, v := range netInterfaces[1:] { | |
if err := exec.Command("sudo", "ip", "link", "set", v.Name, "mtu", mtu).Run(); err != nil { | |
fmt.Println(err) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment