15.3 Changing Your MAC Address

     

As I am sure we are all aware, a MAC (Media Access Control) address is sometimes referred to as our hardware address or station address. It is the 48-bit address where the first 24 bits are a vendor-assigned address (http://www.iana.org/assignments/ethernet- numbers ) and the remaining 24 bits identify individual interfaces. All MAC addresses within a given network should be unique. When a node has an IP packet to send to a node on the same network, it needs to know the destination MAC address. It will look up the ARP (Address Resolution Protocol) cache to see whether it has a corresponding IP to MAC address translation. If not, it will send an ARP packet on the network with the destination IP address but with a destination MAC address of FF:FF:FF:FF:FF:FF. All nodes on the network will read this ARP packet. The node with the corresponding IP address will respond by sending back an ARP packet with its corresponding MAC address. In this way, one node will build up an ARP cache of the nodes with which it is commonly consulting. If after 7 minutes (by default) we haven't communicated with a particular node, the corresponding entry in the ARP cache will be flushed to minimize any kernel memory overhead due to structures that are not being used. If we do not have uniqueness of MAC addresses in our network, this algorithm will break down because more than two nodes could potentially respond to an ARP request. Some people think MAC addresses are unique worldwide; ideally , they would be. A 48-bit address gives us 281,474,976,710,656 potential interface cards in the world. It is hoped that this range of possible addresses would give us complete uniqueness. If every potential vendor number was used and vendors carefully used their allocated addresses (2 24 gives each vendor assigned address a possible 16,777,216 potential interface cards), we would never see duplicates. Unfortunately, duplicates do appear. If they are physically on separate networks, this may pose no problems. If they are on similar networks, this will cause problems.

I have worked with a number of customers who need to be able to change the MAC address for a LAN interface due to the way a particular application works. In one instance, the application was a telecoms application that used the MAC address of an interface to communicate with a telecoms switch. If the LAN interface failed and had to be changed, the application would have to be reconfigured for the new LAN interface. Changing the configuration of the application was a troublesome task, so it was desirable to change the MAC address of the new interface to be the same as the MAC address of the old interface. To change the MAC address, we have two solutions:

  1. Replace the offending card to ensure that the MAC address is now unique; this is counter-productive where we want to maintain the old MAC address for licensing/application considerations.

  2. Change the MAC address via lanadmin .

The first solution is a little drastic, but for many corporations it is a reasonable request of a hardware vendor to supply components that are operational . I know of many sites that will return LAN cards to the vendor if a duplicate MAC address is discovered . The second solution seems more reasonable but is not entirely fool proof. Some licensing software will use the MAC address programmed into the LAN card, so changing the MAC address as described in solution 2 above is not actually changing the programmed MAC address on the LAN card. The lanadmin command is simply setting up a kernel structure that translates the old MAC address to a new MAC address. There is another problem with using solution 2 above; what if you choose a MAC address that conflicts with an existing or future valid MAC address? This has to be considered before proceeding. Should we choose solution 2, there are some considerations before undertaking what is in effect a relatively simple task:

  1. Decide on the new MAC address.

  2. Set up the corresponding startup configuration file to specify the new MAC address.

  3. Change the MAC address by rebooting or running the lanadmin command manually.

Let's look a little closer at these steps:

  1. Decide on the new MAC address .

    We have mentioned the importance of having unique MAC addresses on a given network. If you do need to change the MAC address of a LAN card, try to discover all MAC addresses on your network to ensure that the one you choose is currently unique. A simple way of accomplishing this is to ping the broadcast address of your network and then look up the ARP cache. Most UNIX machines will respond to this, although some Windows-based machines probably will not. Here's an example:

     

     root@hpeos004[]  netstat -in  Name    Mtu  Network         Address         Ipkts   Ierrs Opkts   Oerrs Coll lan0    1500 192.168.0.0     192.168.0.204   8994    0     8929    0     626 lo0     4136 127.0.0.0       127.0.0.1       1118    0     1118    0     0 root@hpeos004[]  ifconfig lan0  lan0: flags=843<UP,BROADCAST,RUNNING,MULTICAST>         inet 192.168.0.204 netmask ffffff00 broadcast 192.168.0.255 root@hpeos004[]  ping 192.168.0.255  PING 192.168.0.255: 64 byte packets 64 bytes from 192.168.0.204: icmp_seq=0. time=0. ms 64 bytes from 192.168.0.203: icmp_seq=0. time=0. ms 64 bytes from 192.168.0.201: icmp_seq=0. time=0. ms 64 bytes from 192.168.0.202: icmp_seq=0. time=0. ms 64 bytes from 192.168.0.100: icmp_seq=0. time=2. ms 64 bytes from 192.168.0.204: icmp_seq=1. time=0. ms 64 bytes from 192.168.0.203: icmp_seq=1. time=0. ms 64 bytes from 192.168.0.201: icmp_seq=1. time=0. ms 64 bytes from 192.168.0.202: icmp_seq=1. time=0. ms 64 bytes from 192.168.0.100: icmp_seq=1. time=1. ms 64 bytes from 192.168.0.204: icmp_seq=2. time=0. ms 64 bytes from 192.168.0.203: icmp_seq=2. time=0. ms 64 bytes from 192.168.0.201: icmp_seq=2. time=0. ms 64 bytes from 192.168.0.202: icmp_seq=2. time=0. ms 64 bytes from 192.168.0.100: icmp_seq=2. time=1. ms ^C ----192.168.0.255 PING Statistics---- 3 packets transmitted, 15 packets received, -400% packet loss round-trip (ms)  min/avg/max = 0/0/2 root@hpeos004[]  arp -a  hpeos001 (192.168.0.201) at 8:0:9:ba:84:1b ether hpeos002 (192.168.0.202) at 8:0:9:c2:69:c6 ether ckpc2.mshome.net (192.168.0.1) at 0:8:74:e5:86:be ether hpeos003 (192.168.0.203) at 0:30:6e:5c:3f:f8 ether 

  2. Set up the corresponding startup configuration file to specify the new MAC address .

    The LAN card you are using will determine the configuration file you need to update. Table 15-2 lists the types of cards you may have, the corresponding kernel driver, and the associated startup configuration file (check your system documentation if do not see your particular network card in this list):

    Table 15-2. Startup Configuration Files for Various Network Cards

    HP-UX 11i

    PCI card (A, L, N, V-class, Superdome)

    HSC card (D, K, T-class)

    EISA card (D-class)

    HP- PB card (K, T-class)

    Core 10/100 card

    Driver

    btlan

    lan2/lan3

    lan2

    lan3

    Config. file

    hpbtlanconf

    hpetherconf

    hpetherconf

    hpetherconf

    Startup script

    hpbtlan

    Hpether

    hpether

    hpether

    Add-on 10/100 card

    Driver

    btlan

    btlan

    btlan0

    btlan1

    Config. file

    hpbtlanconf

    hpbtlanconf

    hpeisabtconf

    hpbasetconf

    Startup script

    hpbtlan

    hpbtlan

    hpeisabt

    hpbaset

    HP-UX 11i

    A, L, N, V, Superdome and Workstations

    rp74X0

    rp84X0

    Core 10/100/1000 card

    Driver

       

    Igelan

    gelan

    Config. file

       

    hpigelanconf

    hpgelanconf

    Startup script

       

    hpigelan

    hpgelan

    Add-on 10/100/1000 card

    Driver

    gelan

    gelan

    gelan

    gelan

    Config. file

    hpgelanconf

    hpgelanconf

    hpgelanconf

    hpgelanconf

    Startup script

    hpgelan

    hpgelan

    hpgelan

    hpgelan


    The individual configuration files may be slightly different in content, but the overall structure is somewhat similar. Here is an example of the configuration file /etc/rc.config.d/hpbtlanconf :

     

     root@hpeos004[]  more /etc/rc.config.d/hpbtlanconf  ##################################################################### # @(#)B.11.11_LR hpbtlanconf $Revision: 1.1.119.1 $ $Date: 97/04/10 15:49:13 $ # hpbase100conf: contains configuration values for HP PCI/HSC 100BASE-T # interfaces # # HP_BTLAN_INTERFACE_NAME   Name of interface (lan0, lan1...) # HP_BTLAN_STATION_ADDRESS  Station address of interface # HP_BTLAN_SPEED            Speed and duplex mode #                           Can be one of : 10HD, 10FD, 100HD, 100FD and #                           AUTO_ON. # # The interface name, major number, card instance and ppa may be # obtained from the lanscan(1m) command. # # The station address and duplex are set through the lanadmin(1m) command. # ##################################################################### HP_BTLAN_INTERFACE_NAME[0]= HP_BTLAN_STATION_ADDRESS[0]= HP_BTLAN_SPEED[0]= ########################################################################### #  The HP_BTLAN_INIT_ARGS are reserved by HP. They are NOT user changable. ########################################################################### HP_BTLAN_INIT_ARGS="HP_BTLAN_STATION_ADDRESS HP_BTLAN_SPEED" # End of hpbtlanconf configuration file root@hpeos004[] 

    For each interface I wish to change, I will copy and paste the three configuration lines, increasing the array subscript by one each time. The important lines for this configuration are:

     

     HP_BTLAN_INTERFACE_NAME[0]="  lan1  " HP_BTLAN_STATION_ADDRESS[0]="  0x080009bbbbbb  " 

    Here I am changing the MAC address of lan1 to 0x080009bbbbbb . If I were to apply this configuration, I would lose all connections on lan1 , so be very careful. I do not have an active connection on this interface, so I should be okay.

  3. Change the MAC address by rebooting or running the lanadmin command manually .

In my case, I will choose to run the lanadmin command manually. I will run it via the startup script /sbin/init.d/hpbtlan to ensure that my configuration file has been set up properly:

 

 root@hpeos004[]  lanscan  Hardware Station        Crd Hdw   Net-Interface  NM  MAC       HP-DLPI DLPI Path     Address        In# State NamePPA        ID  Type      Support Mjr# 0/0/0/0  0x00306E5C4F4F 0   UP    lan0 snap0     1   ETHER     Yes     119 0/2/0/0/4/0 0x00306E46996C 1   UP    lan1 snap1     2   ETHER     Yes     119 0/2/0/0/5/0 0x00306E46996D 2   UP    lan2 snap2     3   ETHER     Yes     119 0/2/0/0/6/0 0x00306E46996E 3   UP    lan3 snap3     4   ETHER     Yes     119 0/2/0/0/7/0 0x00306E46996F 4   UP    lan4 snap4     5   ETHER     Yes     119 root@hpeos004[]  cat /etc/rc.config.d/hpbtlanconf  ##################################################################### # @(#)B.11.11_LR hpbtlanconf $Revision: 1.1.119.1 $ $Date: 97/04/10 15:49:13 $ # hpbase100conf: contains configuration values for HP PCI/HSC 100BASE-T # interfaces # # HP_BTLAN_INTERFACE_NAME   Name of interface (lan0, lan1...) # HP_BTLAN_STATION_ADDRESS  Station address of interface # HP_BTLAN_SPEED            Speed and duplex mode #                           Can be one of : 10HD, 10FD, 100HD, 100FD and #                           AUTO_ON. # # The interface name, major number, card instance and ppa may be # obtained from the lanscan(1m) command. # # The station address and duplex are set through the lanadmin(1m) command. # ##################################################################### HP_BTLAN_INTERFACE_NAME[0]="lan1" HP_BTLAN_STATION_ADDRESS[0]="0x080009bbbbbb" HP_BTLAN_SPEED[0]= ########################################################################### #  The HP_BTLAN_INIT_ARGS are reserved by HP. They are NOT user changable. ########################################################################### HP_BTLAN_INIT_ARGS="HP_BTLAN_STATION_ADDRESS HP_BTLAN_SPEED" # End of hpbtlanconf configuration file root@hpeos004[]  /sbin/init.d/hpbtlan start  root@hpeos004[]  lanscan  Hardware Station        Crd Hdw   Net-Interface  NM  MAC       HP-DLPI DLPI Path     Address        In# State NamePPA        ID  Type      Support Mjr# 0/0/0/0  0x00306E5C4F4F 0   UP    lan0 snap0     1   ETHER     Yes     119   0/2/0/0/4/0 0x080009BBBBBB 1   UP    lan1 snap1     2   ETHER     Yes     119   0/2/0/0/5/0 0x00306E46996D 2   UP    lan2 snap2     3   ETHER     Yes     119 0/2/0/0/6/0 0x00306E46996E 3   UP    lan3 snap3     4   ETHER     Yes     119 0/2/0/0/7/0 0x00306E46996F 4   UP    lan4 snap4     5   ETHER     Yes     119 root@hpeos004[] 

The actual command used would be of the following form (the last command line argument is the PPA number of the interface):

 

 root@hpeos004[]  lanadmin -A 0x080009bbbbbb 1  Old Station Address                 = 0x00306e46996c New Station Address                 = 0x080009bbbbbb root@hpeos004[] 

Before we look at applying an IP address to some of these interfaces, let's mention the speed of our interface and an interesting subject ” auto-negotiation .



HP-UX CSE(c) Official Study Guide and Desk Reference
HP-UX CSE(c) Official Study Guide and Desk Reference
ISBN: N/A
EAN: N/A
Year: 2006
Pages: 434

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net