LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-10-2007, 12:19 AM   #1
yannifan
Member
 
Registered: Feb 2007
Location: Bangalore, India
Distribution: Ubuntu Feisty, Fedora 6 dual boot
Posts: 36

Rep: Reputation: 15
Dual MAC Addresses


Heloo ppl

Im looking for a way to assign two MAC addresses on a single NIC card simultaneously. Is there ne method out there???
Also wanted to know how to create an alias MAC address to a NIC card w/o overrtiting the builtin MAC address...

Thanks in advance
Cheers
 
Old 02-10-2007, 07:33 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
Each NIC has, at any time, only one MAC address.

To give a NIC a different MAC address on the command line, try running:

Code:
ifconfig -help
If you want to do this in a C program:

1. Use the socket(AF_INET,SOCK_DGRAM,0) call to open a socket.

2. Use the SIOCGIFFLAGS ioctl on the socket to get the current flags.

3. Clear the IFF_UP flag in those current flags.

4. Use the SIOCSIFFLAGS ioctl with the changed flags to bring the network card down.

5. Use the SIOCGIFHWADDR ioctl to get the current hardware address.

6. Change the ifr_hwaddr.sa_data bytes (bytes [0] through [5]) to whatever you want.

7. Use the SIOCSIFHWADDR ioctl to set the new hardware address.

8. Use the SIOCSIFFLAGS ioctl to reset the original flags, so that the NIC is now up again.

For help:

Code:
man 2 ioctl
man 2 ioctl_list
 
Old 02-10-2007, 12:38 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Have you looked at this or this?

Last edited by osor; 02-10-2007 at 12:45 PM.
 
Old 02-14-2007, 12:37 AM   #4
yannifan
Member
 
Registered: Feb 2007
Location: Bangalore, India
Distribution: Ubuntu Feisty, Fedora 6 dual boot
Posts: 36

Original Poster
Rep: Reputation: 15
Hello
This is sort of wat i was looking for.

If i run "ip link show", i get details of 2 interfaces with 2 MAC addresses.
If i run "ifconfig", i get 2 interfaces both with original MAC addresses... Wat does this imply...
Sort of confused..
Hellp pllsssss

Cheers
 
Old 02-14-2007, 01:29 PM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by yannifan
Hello
This is sort of wat i was looking for.

If i run "ip link show", i get details of 2 interfaces with 2 MAC addresses.
If i run "ifconfig", i get 2 interfaces both with original MAC addresses... Wat does this imply...
Sort of confused..
Hellp pllsssss

Cheers
Could you post what exactly you did and the resulting output.
 
Old 02-20-2007, 12:00 AM   #6
yannifan
Member
 
Registered: Feb 2007
Location: Bangalore, India
Distribution: Ubuntu Feisty, Fedora 6 dual boot
Posts: 36

Original Poster
Rep: Reputation: 15
vconfig and ip link results

Hello,
First i tried adding an interface using vconfig
ifconfig doesn show the new virtual nic, but ip link show does... Does this mean i have 2 interfaces running???
Results posted below...

[root@localhost ~]# vconfig add eth0 1
WARNING: Could not open /proc/net/vlan/config. Maybe you need to load the 8021q module, or maybe you are not using PROCFS??
Added VLAN with VID == 1 to IF -:eth0:-
WARNING: VLAN 1 does not work with many switches,
consider another number if you have problems.

[root@localhost ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:13:d3:06:8c:e4 brd ff:ff:ff:ff:ff:ff
3: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
4: eth0.1@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop
link/ether 00:13:d3:06:8c:e4 brd ff:ff:ff:ff:ff:ff

[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:133:06:8C:E4
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::213:d3ff:fe06:8ce4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4443 errors:0 dropped:0 overruns:0 frame:0
TX packets:4027 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4836786 (4.6 MiB) TX bytes:679436 (663.5 KiB)
Interrupt:209 Base address:0xa000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1469 errors:0 dropped:0 overruns:0 frame:0
TX packets:1469 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2189856 (2.0 MiB) TX bytes:2189856 (2.0 MiB)


[root@localhost ~]# ip link set dev eth0.1 address 00:07:E9:042:9A
[root@localhost ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:13:d3:06:8c:e4 brd ff:ff:ff:ff:ff:ff
3: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
4: eth0.1@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop
link/ether 00:07:e9:04:d2:9a brd ff:ff:ff:ff:ff:ff

[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:133:06:8C:E4
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::213:d3ff:fe06:8ce4/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:5181 errors:0 dropped:0 overruns:0 frame:0
TX packets:4770 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5453718 (5.2 MiB) TX bytes:837615 (817.9 KiB)
Interrupt:209 Base address:0xa000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1469 errors:0 dropped:0 overruns:0 frame:0
TX packets:1469 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2189856 (2.0 MiB) TX bytes:2189856 (2.0 MiB)

Thanks
 
Old 02-20-2007, 08:46 AM   #7
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Until you bring your interface up, ifconfig will not show it by default. Try “ifconfig -a” to show all interfaces. Also, make sure to “modprobe 8021q” prior to all this.
 
Old 02-25-2007, 12:53 AM   #8
yannifan
Member
 
Registered: Feb 2007
Location: Bangalore, India
Distribution: Ubuntu Feisty, Fedora 6 dual boot
Posts: 36

Original Poster
Rep: Reputation: 15
Thanks a ton to alll....
It worked... I ran the dhclient program and ifconfig showed the configured interfaces....
thank you alll
Cheers
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mapping IP addresses to MAC addresses basilio Linux - Networking 17 09-12-2007 01:48 AM
can MAC addresses be tracked? m00 Linux - Security 7 11-16-2004 09:50 PM
Viewing MAC addresses ivanatora Linux - Networking 1 09-26-2003 12:47 PM
Mac Addresses nixdisciple Linux - Security 6 07-01-2002 10:55 PM
Finding mac addresses Chijtska Linux - Security 5 02-27-2002 04:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration