How can I create a virtual interface similar to the following ifconfig command?

$ sudo ifconfig eth1 hw ether 00:01:02:aa:bb:cc  
SIOCSIFHWADDR: No such device  

This does not work. I want to set the MAC addresses to test my DHCP server's configuration.

How would I do that with the iproute2 suite using the ip link command?

$ sudo ip link add type veth  

This works, but it randomly assigns a MAC address. This is still useful, but I would like to test my dhcpd server with some specific MAC addresses in order to see how it handles the classes I have set up.

My current setup:

$ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 60:eb:69:1b:a0:88 brd ff:ff:ff:ff:ff:ff
    inet 172.16.0.93/24 brd 172.16.0.255 scope global eth0
    inet6 fe80::62eb:69ff:fe1b:a088/64 scope link 
       valid_lft forever preferred_lft forever
7: vboxnet0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
8: veth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 3a:50:38:2e:24:c4 brd ff:ff:ff:ff:ff:ff
link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

Have you tried...

ip link add type veth addr 00:01:02:aa:bb:cc

or

ip link set dev veth0 addr 00:01:02:aa:bb:cc
link|improve this answer
$ sudo ip link add type veth addr 00:01:02:aa:bb:cc Usage: ip link <options> type veth [peer <options>] To get <options> type 'ip link add help' But the second one does work to modify the virtual device to change its ip. – nelaar Jan 25 at 11:50
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.