Is there a way to determine which netdev or IP link interface that a given IP address will route over … in bash/shell language?
This is not about what an IP address is, given a network device name.
Given a destination IP address, bash would automagically determine (with OS assist from its internal IP route table, netstat -i -n
) in printing the network device name.
ip route get
is what you're looking for; maybe it's ip route show to
, depending on whether you checking should be allowed to change the routing state.
See man ip-route
for more details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.