root@test ~]# ip li add link eth0 mac1 address 56:61:4f:7c:56:db type macvlan
[root@test ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 56:61:4F:81:77:F3
inet addr:192.168.1.202 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe81:7df3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2102 errors:0 dropped:0 overruns:0 frame:0
TX packets:111 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:137959 (134.7 KiB) TX bytes:21253 (20.7 KiB)
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)
mac1 Link encap:Ethernet HWaddr 56:61:4F:7C:56:DB
BROADCAST MULTICAST MTU:1500 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)
[root@test ~]# ping 192.168.1.253
PING 192.168.1.253 (192.168.1.253) 56(84) bytes of data.
From 192.168.1.202 icmp_seq=2 Destination Host Unreachable
From 192.168.1.202 icmp_seq=3 Destination Host Unreachable
From 192.168.1.202 icmp_seq=4 Destination Host Unreachable
^C
--- 192.168.1.253 ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4427ms
pipe 3
[root@test ~]# ifconfig mac1 192.168.1.253/24 up
[root@test ~]# ping 192.168.1.253
PING 192.168.1.253 (192.168.1.253) 56(84) bytes of data.
64 bytes from 192.168.1.253: icmp_seq=1 ttl=64 time=0.023 ms
64 bytes from 192.168.1.253: icmp_seq=2 ttl=64 time=0.025 ms
64 bytes from 192.168.1.253: icmp_seq=3 ttl=64 time=0.024 ms
^C
--- 192.168.1.253 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2265ms
rtt min/avg/max/mdev = 0.023/0.024/0.025/0.000 ms
本文出自 “WoSec” 博客,谢绝转载!