Linux

리눅스 mac 순서 변경

jgkim1008 2020. 12. 29. 23:16

#!/usr/bin/sh

mac1=`ifconfig eth0 |grep ether |awk '{print $2}'`

mac2=`ifconfig eth1 |grep ether |awk '{print $2}'`

echo $mac1

echo $mac2

################################# mac change ##############################

sed -i "6s/.*/GRUB_CMDLINE_LINUX=\"crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0 ipv6.disable=1 ifname=ether0:$mac2 ifname=ether1:$mac1\"/g" /etc/default/grub

 

File=/etc/udev/rules.d/70-persistent-net.rules

echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$mac2\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"eth0\"" > $File

echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$mac1\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"eth1\"" >> $File

######################## grub install #######################

grub2-mkconfig -o /boot/grub2/grub.cfg && dracut -f -v && shutdown -r 0