Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question

2 Answers 2

up vote 4 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
share|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 '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

http://baturin.org/docs/iproute2/#Create%20a%20VLAN%20interface

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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