How to determine network interface that will be used to send a packet for an IP


 
Thread Tools Search this Thread
Operating Systems HP-UX How to determine network interface that will be used to send a packet for an IP
# 1  
Old 04-09-2010
Bug How to determine network interface that will be used to send a packet for an IP

Hello,
I'm writing to you because I encountered the following problem. My program displayes all network interfaces that are available in the system, but I would like to add a functionality in which a user can enter a destination address IP (ex. the IP address of the Google search engine) and will get information which network interface will be used to send it. As I know it is associated with reading information from routing table in the system. Maybe you know the API (functions/methods) which I could use to do it in HP-UX ? I program in C/C++, but if you know how to do it in other programming languages (Java, Perl, Python) I will be grateful for any information.

Thank you for any help, tips and suggestions.

Best regards,
Foxrafi

---------- Post updated at 12:53 PM ---------- Previous update was at 01:55 AM ----------

Just to share with you what I've already learnt. On Solaris there is a command: "route get <ip address>" which shows the network interface that will be used for network communication with this IP address. Example:
route get 9.168.23.12.
As source code for OpenSolaris is available publicly it shouldn't be difficult to find what system calls are used to it, I think so.

I've also found a short discussion about this topic on the HP-UX forum: here .
It turns out that on HP-UX you're not able to achieve it in a simple way.

If you have any other ideas how solve my problem Smilie, I will appreciate that.
# 2  
Old 04-12-2010
You can always have a look at the /etc/rc.config.d/netconf file to see what/how interfaces are configured...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Packet going out of wrong interface due to OS automatically added cache route with lower metric

RHEL 7.0, IPV6 Scenario: I have routed specific network using network scripts. 1. "ip -6 route show" shows that route has been added. ( with metric 1024) 2. Ping of the specific IP through that route is successful. 3. Now after few days, for some reason, we see that cache route appears for... (3 Replies)
Discussion started by: msr1981
3 Replies

2. Solaris

Determine PCI Endpoint for a Serial Interface.

Hi Folks, Here is one for the real Solaris aficionados on the site; I have a T5240 and have to create an I/O domain with access to the serial port, in this case /dev/term/a and although I have been through the documentation I'm having some issues in identifying the device to assign. What I... (2 Replies)
Discussion started by: gull04
2 Replies

3. Shell Programming and Scripting

Bash- Determine what interface is online

Hey guys, I want to use a a quick bash script/command to determine what network interface is connected to the internet so I can pipe it out to become a variable, in order so the user does not have to manually type it in each time or have to 'hardcode' the variable into the script. I know about... (6 Replies)
Discussion started by: 3therk1ll
6 Replies

4. UNIX for Dummies Questions & Answers

Adding a network interface to a bonded interface

I have a RHEL 5 system with a bonded interface configure using only one network port (eth0). So I have config file for ifcfg-bond0 and ifcfg-eth. I'd like to configure eth5 to be the second SLAVE in the bond. My question is, after I modify ifcfg-eth5, can I add eth5 to the bond0 interface without... (1 Reply)
Discussion started by: westmoreland
1 Replies

5. Solaris

No network cable But Network interface is UP and Running

I've one Netra 240 After changing main board and system configuration card reader, Network is not accessible any more, Network interfaces are always UP and Running even when there is no cable connected to Network interfaces. I tried to restart and plumb/unplumb with no luck. ifconfig -a... (7 Replies)
Discussion started by: samer.odeh
7 Replies

6. Solaris

Packet loss on ce interface.

Hi, I am using the ce interface on my Solaris 9 server and there is significant packet loss when transmitting large packets. Does anyone have a fix for this? ----10.1.0.0 PING Statistics---- 51 packets transmitted, 42 packets received, 17% packet loss round-trip (ms) min/avg/max =... (12 Replies)
Discussion started by: sparcman
12 Replies

7. HP-UX

how to get network packet size

how to get network packet size I would like get network output rate(kb/sec) I type command "netstat -i" Ipkts Ierrs Opkts Oerrs 653387 0 678202 0 but i didn't know what is it packet size , how could i get it? (1 Reply)
Discussion started by: alert0919
1 Replies

8. Solaris

Determine Solaris box network interface?

Given a new Solaris box, with a fresh, unconfigured install on it, how does one figure out what kind of network interface it has (bge,le, hme, etc)? (8 Replies)
Discussion started by: akbar
8 Replies

9. IP Networking

How to determine the interface?

Given the interfaces on a firewall: eth0 Link encap:Ethernet HWaddr 02:40:67:34:F5:47 inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0 eth1 Link encap:Ethernet HWaddr 86:23:98:45:35:56 inet addr:123.45.240.69 Bcast:255.255.255.255 ... (2 Replies)
Discussion started by: kikikaka
2 Replies

10. Programming

determine if a ethernet interface is up

Howto check if a ethernet interface is up? It's impossible to determine via the ipaddress i have learned, or? Can someone please give me a hint on howto do? Environment == Linux x86 GNU GCC. :D regards Esaia (2 Replies)
Discussion started by: Esaia
2 Replies
Login or Register to Ask a Question