netlink/netlink_linux.go
func NetworkSetMTU(iface *net.Interface, mtu int) error {
	s, err := getNetlinkSocket()
	if err != nil {
		return err
	}
	defer s.Close()

	wb := newNetlinkRequest(syscall.RTM_SETLINK, syscall.NLM_F_ACK)

	msg := newIfInfomsg(syscall.AF_UNSPEC)
	msg.Type = syscall.RTM_SETLINK
	msg.Flags = syscall.NLM_F_REQUEST
	msg.Index = int32(iface.Index)
	msg.Change = DEFAULT_CHANGE
	wb.AddData(msg)
	wb.AddData(uint32Attr(syscall.IFLA_MTU, uint32(mtu)))

	if err := s.Send(wb); err != nil {
		return err
	}
	return s.HandleAck(wb.Seq)
}
func NetworkSetMTU(iface *net.Interface, mtu int) error {
	s, err := getNetlinkSocket()
	if err != nil {
		return err
	}
	defer s.Close()

	wb := newNetlinkRequest(syscall.RTM_SETLINK, syscall.NLM_F_ACK)

	msg := newIfInfomsg(syscall.AF_UNSPEC)
	msg.Type = syscall.RTM_SETLINK
	msg.Flags = syscall.NLM_F_REQUEST
	msg.Index = int32(iface.Index)
	msg.Change = DEFAULT_CHANGE
	wb.AddData(msg)
	wb.AddData(uint32Attr(syscall.IFLA_MTU, uint32(mtu)))

	if err := s.Send(wb); err != nil {
		return err
	}
	return s.HandleAck(wb.Seq)
}
func NetworkSetMTU ( iface * net . Interface , mtu int ) error { s , err := getNetlinkSocket ( ) if err != nil { return err } defer s . Close ( ) wb := newNetlinkRequest ( syscall . RTM_SETLINK , syscall . NLM_F_ACK ) msg := newIfInfomsg ( syscall . AF_UNSPEC ) msg . Type = syscall . RTM_SETLINK msg . Flags = syscall . NLM_F_REQUEST msg . Index = int32 ( iface . Index ) msg . Change = DEFAULT_CHANGE wb . AddData ( msg ) wb . AddData ( uint32Attr ( syscall . IFLA_MTU , uint32 ( mtu ) ) ) if err := s . Send ( wb ) ; err != nil { return err } return s . HandleAck ( wb . Seq ) }
// Set link Maximum Transmission Unit
// This is identical to running: ip link set dev $name mtu $MTU
// bridge is a bitch here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=292088
// https://bugzilla.redhat.com/show_bug.cgi?id=697021
// There is a discussion about how to deal with ifcs joining bridge with MTU > 1500
// Regular network nterfaces do seem to work though!
Set link Maximum Transmission Unit This is identical to running : ip link set dev $name mtu $MTU bridge is a bitch here https : // bugs . debian . org / cgi - bin / bugreport . cgi?bug = 292088 https : // bugzilla . redhat . com / show_bug . cgi?id = 697021 There is a discussion about how to deal with ifcs joining bridge with MTU > 1500 Regular network nterfaces do seem to work though!