LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   More than one MAC addresses on single NIC (https://www.linuxquestions.org/questions/linux-networking-3/more-than-one-mac-addresses-on-single-nic-834413/)

shadyabhi 09-25-2010 08:14 AM

More than one MAC addresses on single NIC
 
My machine has ONE ethernet card and is on a LAN.

IP address is assigned to hosts using DHCP.

I can have more than one MAC address on LAN by running Virtual Machine and setting network to bridged. This way, my virtual machine simply acts like there is one more machine in the network.

Running VMWare for this job is a a bit heavy on resources. Is there a way so that I can I can have 2 or more ip addresses with different MAC address on the same machine without having to run VirtualBox.

By googling, I think its related to bridging and tap. And, I am sure that its NOT IP-ALIASING because in ip-aliasing both the ip addresses have the same MAC address.

Basically, I want my system to have interfaces like:-
  • eth0 - which was originally present
  • lo - thats always present :|
  • newint0 - New interface with new MAC address and IP addresses which can access my LAN directly. Its like if I bind, let us suppose curl to this interface, its like a different connection
  • newint1 - . . . . .

Nemesiz 09-25-2010 10:37 AM

You can use http://www.primianotucci.com/default.php?view=57
If you will try to redirect some of the ports with iptables it may not work (at least i can not figure out why)

jefro 09-25-2010 11:26 PM

Wonder if multiple ip addresses would suite your needs?

shadyabhi 09-26-2010 01:07 AM

./multimac is not working...
 
Quote:

Originally Posted by Nemesiz (Post 4108700)
You can use http://www.primianotucci.com/default.php?view=57
If you will try to redirect some of the ports with iptables it may not work (at least i can not figure out why)

Code:

[root@ArchLinux multimac]# pwd
/media/misc1/Downloads/multimac
[root@ArchLinux multimac]# ./multimac 5
Allocating 5 taps...
5 of 5
.:: Gone into daemonland ::.
[root@ArchLinux multimac]# Starting Master Thread... OK
Starting Interface Threads...
5 of 5
[root@ArchLinux multimac]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1C:C0:37:5E:25 
          inet addr:10.100.98.112  Bcast:10.100.98.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4888 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2998 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4759932 (4.5 Mb)  TX bytes:218334 (213.2 Kb)
          Interrupt:20 Memory:e0380000-e03a0000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:600 (600.0 b)  TX bytes:600 (600.0 b)

[root@ArchLinux multimac]# modprobe bridge
[root@ArchLinux multimac]# modprobe tun
[root@ArchLinux multimac]# brctl addbr br0
[root@ArchLinux multimac]# brctl addif br0 eth0
[root@ArchLinux multimac]# brctl addif br0 tap0
[root@ArchLinux multimac]# ifconfig eth0 down
[root@ArchLinux multimac]# ifconfig eth0 0.0.0.0 up
[root@ArchLinux multimac]# ifconfig tap0 0.0.0.0 up
[root@ArchLinux multimac]# ifconfig br0 10.100.98.112 netmask 255.255.255.0 up
[root@ArchLinux multimac]# ifconfig tap1 hw ether 00:1C:C0:37:5E:26
[root@ArchLinux multimac]# ifconfig
br0      Link encap:Ethernet  HWaddr 00:1C:C0:37:5E:25 
          inet addr:10.100.98.112  Bcast:10.100.98.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:229 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:32644 (31.8 Kb)  TX bytes:5011 (4.8 Kb)

eth0      Link encap:Ethernet  HWaddr 00:1C:C0:37:5E:25 
          inet addr:10.100.98.112  Bcast:10.100.98.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8177 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3187 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5036971 (4.8 Mb)  TX bytes:238726 (233.1 Kb)
          Interrupt:20 Memory:e0380000-e03a0000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:68 errors:0 dropped:0 overruns:0 frame:0
          TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5174 (5.0 Kb)  TX bytes:5174 (5.0 Kb)

tap0      Link encap:Ethernet  HWaddr FE:D9:89:FC:6D:C9 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:216 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:0 (0.0 b)  TX bytes:35130 (34.3 Kb)

[root@ArchLinux multimac]# ifconfig tap1 10.100.98.252 netmask 255.255.255.0 up
[root@ArchLinux multimac]# ifconfig
br0      Link encap:Ethernet  HWaddr 00:1C:C0:37:5E:25 
          inet addr:10.100.98.112  Bcast:10.100.98.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:475 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:73853 (72.1 Kb)  TX bytes:5089 (4.9 Kb)

eth0      Link encap:Ethernet  HWaddr 00:1C:C0:37:5E:25 
          inet addr:10.100.98.112  Bcast:10.100.98.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8463 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3227 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5103969 (4.8 Mb)  TX bytes:245013 (239.2 Kb)
          Interrupt:20 Memory:e0380000-e03a0000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:88 errors:0 dropped:0 overruns:0 frame:0
          TX packets:88 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:6980 (6.8 Kb)  TX bytes:6980 (6.8 Kb)

tap0      Link encap:Ethernet  HWaddr FE:D9:89:FC:6D:C9 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15 errors:0 dropped:0 overruns:0 frame:0
          TX packets:425 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:4871 (4.7 Kb)  TX bytes:73437 (71.7 Kb)

tap1      Link encap:Ethernet  HWaddr 00:1C:C0:37:5E:26 
          inet addr:10.100.98.252  Bcast:10.100.98.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:425 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:73437 (71.7 Kb)  TX bytes:4871 (4.7 Kb)

[root@ArchLinux multimac]# ping 10.100.98.4
PING 10.100.98.4 (10.100.98.4) 56(84) bytes of data.
64 bytes from 10.100.98.4: icmp_seq=1 ttl=255 time=0.710 ms
64 bytes from 10.100.98.4: icmp_seq=2 ttl=255 time=0.722 ms
64 bytes from 10.100.98.4: icmp_seq=3 ttl=255 time=1.51 ms
^C
--- 10.100.98.4 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.710/0.983/1.518/0.378 ms
[root@ArchLinux multimac]#

10.100.98.4 is the ip address of my gateway. But, I am not able to surf internet after this.. What is going wrong?

carltm 09-26-2010 05:20 AM

What is the output of "route -n"? That will show all the current
routes. My guess is that the default route went away when you ran
"ifconfig eth0 down" and it wasn't restored after "ifconfig eth0 up".

Nemesiz 09-27-2010 02:32 AM

Use tap1...tapx as "eth" network devices.

ifconfig eth0 0.0.0.0
ifconfig br0 0.0.0.0

ifconfig tap1 IP1 netmask MASK
ifconfig tap2 IP2 netmask MASK
ip r add default via GATEWAY_IP dev tap1

If you have a problem with 2 or more IP from the same range of IP try to look more info here or in google

Code:

root@nmz:~# ifconfig
eth0      Link encap:Ethernet  HWaddr XXX
          inet6 addr: XXX/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:257840 errors:0 dropped:0 overruns:0 frame:0
          TX packets:207634 errors:0 dropped:0 overruns:0 carrier:1
          collisions:0 txqueuelen:1000
          RX bytes:332839363 (317.4 MiB)  TX bytes:26177206 (24.9 MiB)

inet0    Link encap:Ethernet  HWaddr XXX 
          inet6 addr: XXX/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:827 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:224659 (219.3 KiB)  TX bytes:3191 (3.1 KiB)

tap0      Link encap:Ethernet  HWaddr 42:f2:e1:fc:c2:2a 
          inet6 addr: fe80::40f2:e1ff:fefc:c22a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:207594 errors:0 dropped:0 overruns:0 frame:0
          TX packets:257878 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:26079800 (24.8 MiB)  TX bytes:332828057 (317.4 MiB)

tap1      Link encap:Ethernet  HWaddr 3a:4f:ba:7c:c7:6e 
          inet addr:192.168.0.3  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::384f:baff:fe7c:c76e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:257878 errors:0 dropped:0 overruns:0 frame:0
          TX packets:207594 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:332828057 (317.4 MiB)  TX bytes:26079800 (24.8 MiB)

Code:

root@nmz:~# ip r
192.168.0.0/24 dev tap1  proto kernel  scope link  src 192.168.0.3
default via 192.168.0.1 dev tap1


helleon 09-20-2012 09:59 PM

I've same issue which need different MAC address to sub-interface and commnicate to others networks. I used multimac and success to assign different MAC address to tap1~tap5, but all interface use br0 MAC address to identity itself. I have no idea how to resolve it.

Code:

br0      Link encap:Ethernet  HWaddr 00:0c:29:68:d6:93 
          inet addr:192.168.192.10  Bcast:192.168.192.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe68:d693/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:81957 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:4030588 (4.0 MB)  TX bytes:168 (168.0 B)

eth0      Link encap:Ethernet  HWaddr 00:0c:29:68:d6:89 
          inet addr:10.103.50.199  Bcast:10.103.51.255  Mask:255.255.254.0
          inet6 addr: 2001:470:80b7:6732:c1a:cf08:ff08:770f/64 Scope:Global
          inet6 addr: 2001:470:80b7:6732:20c:29ff:fe68:d689/64 Scope:Global
          inet6 addr: fe80::20c:29ff:fe68:d689/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:339 errors:0 dropped:0 overruns:0 frame:0
          TX packets:146 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:31939 (31.9 KB)  TX bytes:16803 (16.8 KB)
          Interrupt:19 Base address:0x2000

eth1      Link encap:Ethernet  HWaddr 00:0c:29:68:d6:93 
          inet6 addr: fe80::20c:29ff:fe68:d693/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:81966 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2078 (2.0 KB)  TX bytes:5179008 (5.1 MB)
          Interrupt:18 Base address:0x2080

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:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tap0      Link encap:Ethernet  HWaddr b2:cb:56:c7:f5:af 
          inet6 addr: fe80::b0cb:56ff:fec7:f5af/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:68149 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2769 errors:0 dropped:0 overruns:2642 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:4100814 (4.1 MB)  TX bytes:215838 (215.8 KB)

tap1      Link encap:Ethernet  HWaddr aa:11:22:33:44:01 
          inet addr:192.168.192.21  Bcast:192.168.192.255  Mask:255.255.255.0
          inet6 addr: fe80::a811:22ff:fe33:4401/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2769 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13718 errors:0 dropped:0 overruns:13617 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:215838 (215.8 KB)  TX bytes:827780 (827.7 KB)

tap2      Link encap:Ethernet  HWaddr aa:11:22:33:44:02 
          inet addr:192.168.192.22  Bcast:192.168.192.255  Mask:255.255.255.0
          inet6 addr: fe80::a811:22ff:fe33:4402/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2768 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13676 errors:0 dropped:0 overruns:13515 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:215760 (215.7 KB)  TX bytes:821360 (821.3 KB)

tap3      Link encap:Ethernet  HWaddr aa:11:22:33:44:03 
          inet addr:192.168.192.23  Bcast:192.168.192.255  Mask:255.255.255.0
          inet6 addr: fe80::a811:22ff:fe33:4403/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2768 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13504 errors:0 dropped:0 overruns:13413 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:215760 (215.7 KB)  TX bytes:810648 (810.6 KB)

tap4      Link encap:Ethernet  HWaddr aa:11:22:33:44:04 
          inet addr:192.168.192.24  Bcast:192.168.192.255  Mask:255.255.255.0
          inet6 addr: fe80::a811:22ff:fe33:4404/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2768 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13810 errors:0 dropped:0 overruns:13656 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:215760 (215.7 KB)  TX bytes:832576 (832.5 KB)

tap5      Link encap:Ethernet  HWaddr aa:11:22:33:44:05 
          inet addr:192.168.192.25  Bcast:192.168.192.255  Mask:255.255.255.0
          inet6 addr: fe80::a811:22ff:fe33:4405/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2768 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13441 errors:0 dropped:0 overruns:13278 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:215760 (215.7 KB)  TX bytes:808450 (808.4 KB)

Code:

arp -a
  192.168.192.21        00-0c-29-68-d6-93
  192.168.192.22        00-0c-29-68-d6-93
  192.168.192.23        00-0c-29-68-d6-93
  192.168.192.24        00-0c-29-68-d6-93
  192.168.192.25        00-0c-29-68-d6-93



All times are GMT -5. The time now is 03:32 PM.