Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: How to increment a MAC Address?

by Anonymous Monk
on Dec 13, 2011 at 13:51 UTC ( [id://943341]=note: print w/replies, xml ) Need Help??


in reply to Re: How to increment a MAC Address?
in thread How to increment a MAC Address?

Here i using the code for increment MAC address of last bit after increment last bit overflow so to over come again recount from starting eg: last position is FF then after we increment by 1 we start count by 00 ----------------
#!/bin/sh mac=$(ifconfig eth0|grep HWaddr|awk '{print $5}'| tr '[a-z]' '[A-Z]' | + cut -d ':' -f1-5) maclast=$(ifconfig eth0|grep HWaddr|awk '{print $5}'| tr '[a-z]' '[A-Z +]' | cut -d ':' -f6) echo "Mac address= $mac:$maclast" decmac=$(echo "ibase=16; $maclast"|bc) if [ $decmac -eq '241' ] then macinc='00' else incout=`expr $decmac + 1 ` macinc=$(echo "obase=16; $incout"|bc) fi echo "Mac address= $mac:$macinc"
OUTPUT:
Mac address= 00:19:D1:F6:F7:F1 Mac address= 00:19:D1:F6:F7:00

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://943341]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-04-16 09:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found