How to get the correct IP on a Linux server?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get the correct IP on a Linux server?
# 8  
Old 08-25-2013
I am no longer competent on Linux (it's been more than 5 years since I used it regularly), but perhaps this will provide more specific information than the simpler ip route?
Code:
ip route get <addr>

Where <addr> is any destination address to which you do not have a direct host-host or host-subnet route. Perhaps you could use 8.8.8.8 (one of Google's public dns ip addresses).

ip route get doesn't actually send a packet, it only uses the kernel's routing information to determine how such a packet would be sent.

Regards,
Alister
These 2 Users Gave Thanks to alister For This Post:
# 9  
Old 08-25-2013
Perfect
Thank you Smilie

This gives exactly what i want:
Code:
ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux correct permissions for .bash_aliases

Above is a search string I tried on Google that produced lots of hits but not much in the way of clues. And I wasn't looking for clues. So I decided, for the first time, to ask the question here. What are the correct permissions for the .bash_aliases file? iwrong (1 Reply)
Discussion started by: iamwrong
1 Replies

2. Windows & DOS: Issues & Discussions

Passwordless login from Linux server to windows server

Hi, I am a newbie and has been given a task to connect to a windows server from a linux server (using putty of course; for file transfer) that too passwordless. Searching through google I found "ssh-keygen" but this also couldn't work because as I tried ssh <username>@<windowsServerIP>, it says... (5 Replies)
Discussion started by: pratria
5 Replies

3. Linux

How to connect Linux server (configure two way authentication) with Windows server?

Hi my name is Manju. ->I have configure the two way authentication on my linux server. ->Now I am able to apply two way authenticator on particuler user. ->Now I want to map this linux server to my AD server. ->Kindly tell me how to map AD(Active Directory) with this linux server. ... (0 Replies)
Discussion started by: manjusharma128
0 Replies

4. Homework & Coursework Questions

Configure the AD Window server with Linux server(google Authenticator is installed)

Hi my name is Manju. ->I have configure the two way authentication on my linux server. ->Now I am able to apply two way authenticator on particuler user. ->Now I want to map this linux server to my AD server. ->Kindly tell me how to map AD(Active Directory) with this linux server. ... (2 Replies)
Discussion started by: manjusharma128
2 Replies

5. Shell Programming and Scripting

Copy files from Linux server to Windows server

Hi All, I am generating report in a Linux server and once the report is generated the report(.txt file) needs to be automatically saved in a Windows servers. So i am looking for a script to transfer the file automatically from Linux server to Windows server? Please advise. Thanks... (3 Replies)
Discussion started by: arunmanas
3 Replies

6. Shell Programming and Scripting

Connect (SSH) to Windows server via Linux server through a script and passing command.. but failing

I am trying to connect to Windows server via Linux server through a script and run two commands " cd and ls " But its giving me error saying " could not start the program" followed by the command name i specify e g : "cd" i am trying in this manner " ssh username@servername "cd... (5 Replies)
Discussion started by: sunil seelam
5 Replies

7. Shell Programming and Scripting

Copy folder and files from unix server to linux server

We would be migrating unix solaries to Linux redhat. Basically source is unix and target is linux. i would like to copy entire file system unix/source/* to target linux/souce/* but target linux has only folder setup so what ever files copied need to be placed in the linux server with same... (8 Replies)
Discussion started by: balajikalai
8 Replies

8. Red Hat

microsoft Server 2008 Active authentication to a linux server

Hi, Please could someone advise I'm trying to use winscp from a Window server 2008 R2, but i need to add the authentication key to access the linux rh 5.4 servers ? What is the best way of approaching this ? If there are any web links that could help me do this, that would be good. ... (1 Reply)
Discussion started by: venhart
1 Replies

9. UNIX for Dummies Questions & Answers

Correct time in server

Hi, we have a server which when we check time it has different time for different user. When we're using root user, the time is correct but when we login as individual user the time is delayed 1 hour. How can we correct the time when we're using individual user like my own user? Please help me to... (4 Replies)
Discussion started by: ayhanne
4 Replies
Login or Register to Ask a Question