liushuhe1990

修改linux的网卡名字

  一、命令修改

ip link set eth0 name eth01
ip link set eth1 name eth10
ip link set eth2 name eth23
ip link set eth3 name eth32


ip link set eth01 name eth1
ip link set eth10 name eth0
ip link set eth23 name eth3
ip link set eth32 name eth2 
修改前先ifconfig eth* down   

修改mac

ifconfig eth0 down
ifconfig eth1 down
ifconfig eth2 down
ifconfig eth3 down

if [ -f /etc/mac.conf ]
then
        mac0=`cat /etc/mac.conf | head -1 | tail -1 | sed \'s/eth0_mac=//g\'`
        mac1=`cat /etc/mac.conf | head -2 | tail -1 | sed \'s/eth1_mac=//g\'`
        mac2=`cat /etc/mac.conf | head -3 | tail -1 | sed \'s/eth2_mac=//g\'`
        mac3=`cat /etc/mac.conf | head -4 | tail -1 | sed \'s/eth3_mac=//g\'`

        ifconfig eth0 hw ether $mac0
        ifconfig eth1 hw ether $mac1
        ifconfig eth2 hw ether $mac2
        ifconfig eth3 hw ether $mac3
fi

sleep 1

ifconfig eth0 up
ifconfig eth1 up
ifconfig eth2 up
ifconfig eth3 up

  

二、代码修改(am335x本体网卡)

D:\z_linux_picohood_project\board-support\linux-4.4.x-mainline\drivers\net\ethernet\ti\cpsw.c

static int cpsw_probe(struct platform_device *pdev)
{
	struct clk			*clk;
	struct cpsw_platform_data	*data;
	struct net_device		*ndev;
	struct cpsw_priv		*priv;
	struct cpdma_params		dma_params;
	struct cpsw_ale_params		ale_params;
	void __iomem			*ss_regs;
	void __iomem			*cpts_regs;
	struct resource			*res, *ss_res;
	const struct of_device_id	*of_id;
	struct gpio_descs		*mode;
	u32 slave_offset, sliver_offset, slave_size;
	struct cpsw_common		*cpsw;
	int ret = 0, i;
	int irq;
        .....................................
        .....................................

  

四、代码修改(usb网卡)

D:\z_linux_picohood_project\board-support\linux-4.4.x-mainline\drivers\net\usb\usbnet.c

int usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
{
	struct usbnet			*dev;
	struct net_device		*net;
	struct usb_host_interface	*interface;
	struct driver_info		*info;
	struct usb_device		*xdev;
	int				status;
	const char			*name;
	
	struct usbnet			*dev11;
	struct usb_driver 	*driver = to_usb_driver(udev->dev.driver);
        ....................................
        ....................................

 

 

 

分类:

技术点:

相关文章: