func NetworkChangeName(iface *net.Interface, newName string) error {
	if len(newName) >= IFNAMSIZ {
		return fmt.Errorf("Interface name %s too long", newName)
	}

	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.Index = int32(iface.Index)
	msg.Change = DEFAULT_CHANGE
	wb.AddData(msg)

	nameData := newRtAttr(syscall.IFLA_IFNAME, zeroTerminated(newName))
	wb.AddData(nameData)

	if err := s.Send(wb); err != nil {
		return err
	}

	return s.HandleAck(wb.Seq)
}
func NetworkChangeName(iface *net.Interface, newName string) error {
	if len(newName) >= IFNAMSIZ {
		return fmt.Errorf("Interface name %s too long", newName)
	}

	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.Index = int32(iface.Index)
	msg.Change = DEFAULT_CHANGE
	wb.AddData(msg)

	nameData := newRtAttr(syscall.IFLA_IFNAME, zeroTerminated(newName))
	wb.AddData(nameData)

	if err := s.Send(wb); err != nil {
		return err
	}

	return s.HandleAck(wb.Seq)
}
func NetworkChangeName ( iface * net . Interface , newName string ) error { if len ( newName ) >= IFNAMSIZ { return fmt . Errorf ( " " , newName ) } 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 . Index = int32 ( iface . Index ) msg . Change = DEFAULT_CHANGE wb . AddData ( msg ) nameData := newRtAttr ( syscall . IFLA_IFNAME , zeroTerminated ( newName ) ) wb . AddData ( nameData ) if err := s . Send ( wb ) ; err != nil { return err } return s . HandleAck ( wb . Seq ) }
// Rename a particular interface to a different name
// !!! Note that you can't rename an active interface. You need to bring it down before renaming it.
// This is identical to running: ip link set dev ${oldName} name ${newName}
Rename a particular interface to a different name !!! Note that you can t rename an active interface . You need to bring it down before renaming it . This is identical to running : ip link set dev $ { oldName } name $ { newName }