This is similar to what we do in a router if we want to ping a destination IP from a specific source IP that we want.is source ip selfip? if yes, have you tried ping -I option? but if not (selfip), i am not aware of.
e.g.
external vlan is in 172.28.20.0/24 subnet
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list net self 172.28.20.11/24
net self 172.28.20.11/24 {
address 172.28.20.11/24
allow-service {
default
}
traffic-group traffic-group-local-only
vlan external
}
[root@ve11a:Active:Changes Pending] config tmsh
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list net vlan external
net vlan external {
if-index 112
interfaces {
1.1 { }
}
tag 4094
}
ping to external host (172.28.26.70) from specific source ip (200.200.200.11)
[root@ve11a:Active:Changes Pending] config ping -c 3 -I 200.200.200.11 172.28.26.70
PING 172.28.26.70 (172.28.26.70) from 200.200.200.11 : 56(84) bytes of data.
^C
--- 172.28.26.70 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms
trace shows 4094 vlan and 200.200.200.11 source ip
[root@ve11a:Active:Changes Pending] config tcpdump -nni 0.0 -e icmp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on 0.0, link-type EN10MB (Ethernet), capture size 96 bytes
08:01:43.130623 00:50:56:b3:1c:32 > 00:01:e8:d5:d4:47, ethertype 802.1Q (0x8100), length 102: vlan 4094, p 0, ethertype IPv4, 200.200.200.11 > 172.28.26.70: ICMP echo request, id 8024, seq 1, length 64
08:01:44.130039 00:50:56:b3:1c:32 > 00:01:e8:d5:d4:47, ethertype 802.1Q (0x8100), length 102: vlan 4094, p 0, ethertype IPv4, 200.200.200.11 > 172.28.26.70: ICMP echo request, id 8024, seq 2, length 64
08:01:45.129976 00:50:56:b3:1c:32 > 00:01:e8:d5:d4:47, ethertype 802.1Q (0x8100), length 102: vlan 4094, p 0, ethertype IPv4, 200.200.200.11 > 172.28.26.70: ICMP echo request, id 8024, seq 3, length 64