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 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 brd 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

Have you tried...

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


ip link set dev veth0 addr 00:01:02:aa:bb:cc
  • $ 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. – nelaaro Jan 25 '12 at 11:50
  • 1
    You've probably solved it already, but if you look at the help from 'ip link help' you'll see this answer is missing the NAME of the interface (which follows the set of options). – sillyMunky Feb 27 '13 at 23:20

Create a VLAN interface ip link add name ${VLAN interface name} link ${parent interface name} type vlan id ${tag} Examples: ip link add name eth0.110 link eth0 type vlan id 110


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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