Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a VPS with 4 IP addresses. I am changing the IP address of eth0 on daily basis. eht0:1 has its own IP address.

eth0 (192.168.1.3, 192.168.1.4, 192.168.1.5)
eth0:1 (192.168.2.1)

I have my custom written Python scripts those are continuously uploading data to remote database and other processes. I want to know which interface my scripts will use?

Because I am changing the eth0 IP address daily, I want that my script will use only eth0. And I want to use eth0:1 for ping and http apache server.

share|improve this question

closed as unclear what you're asking by slm, Anthon, peterph, jasonwryan, terdon Dec 28 '13 at 23:45

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

It depends on your routing table configuration, not NIC interfaces.

So to find out which interface it is using, you need to know which gateway kernel uses to route the packets, e.g

%> ip route get 192.168.56.99
   192.168.56.20 dev vboxnet0  src 192.168.56.1 
       cache

Fom the output you can tell the interface in use is vboxnet0

share|improve this answer

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