I have 4 running eth ports on my Linux machine (eth0 through eth3). So if i give the command host <hostname>, which eth port's ipaddress will be returned? how does linux decide which eth port's ip address to be returned?
Thanks,
LinuxPenseur
host does not look at your local IPs, it looks up the hostname based on the rules specified in /etc/nsswitch.conf
In nsswitch.conf you will typically have this entry:
hosts: files dns
This means that the resolver will first check /etc/hosts, if it cannot find anything there it'll check /etc/resolv.conf and ask the specified DNS servers for the IP, optionally appending the "search" and "domain" suffixes specified in resolv.conf
See http://www.faqs.org/docs/linux_network/x-087-2-resolv.library.html
What's your "primary" interface? That one is used.
http://ubuntuforums.org/archive/index.php/t-1120370.html
Related
Is there any command which determine physical IP of the system ( on each physical Interface)?
Actually I want to make a script which un plump all IP except physical IP.
Thanks in advance,
Deepak
There will be one IP address for a server, since it is an entity in network for that server. To get the IP adrress in linux:
hostname -i
...on each physical Interface...
That would be ifconfig.
You can also call hostname -I (note the uppercase "I"), which lists all configured IP's except loopback and IPv6 link-local.
I like the idea of running my own nameserver (BIND) but if I do that, I can't get the benefit of blocking nasty websites by putting them in /etc/hosts
DNSMasq is able to refer to /etc/hosts but rather than specifying an "upstream" dnsserver, I'd like it to be able to use BIND on the same machine. However, they both need to use the same port.
Is this possible? I couldn't find anything about this in regular searching.
I suppose an alternative would be to run another Linux instance in a VM and run DNSMasq there (say) but I'd like to not have to do this.
you could assign multiple ip addresses to the same interface, either with
ip addr add <address>/32 dev eth0
or using
ifconfig eth0:1 <address>
then bind one server to one address, the other server to the second address.
Which server is queried depends now on the ip address your queries are sent to.
The examples assume that your eth interface is eth0.
i have few Centos 5.1 servers, recently they took very long time to communicate eachother, it looks like for every request it checks local server in public dns, is there is anyway to give option in /etc/resolve.conf to disable dns for some IP address ?
Add the server names and their IP addresses to the file /etc/hosts, e.g.
10.0.0.100 server1 server1-alias
10.0.0.101 server2
and then make sure that you list the keyword files before the keyword dns for the hosts entry in /etc/nsswitch.conf, i.e. that file should have a line that looks something like this:
hosts: files dns
After that, any attempts to resolve hostnames or IP addresses will first consult the /etc/hosts file, and only if that is unsuccessful go on to do a DNS lookup.
For diagnostic purposes I would like to be able to find out if a customer has a hostname failure because of a HOSTS file entry. Is it possible to detect that a DNS query was resolved by HOSTS or DNS?
(Of course I'm curious about multiple OSes: Windows, HPUX, AIX, Linux, Mac)
I suspect it may be possible if I could bypass the hostname resolution sequencing configuration of the machine. Of course reading the HOSTS file directly is an option but if there's an in memory problem (i.e. virus, or just changed to remove the misconfiguration but not taken effect yet) then it wouldn't be helpful.
On Windows, if you are looking up server1 you can compare the IP address printed in the output of ping server1 with the output of the nslookup server1 command.
This URL states that on Windows, nslookup does not use the hosts file:
https://serverfault.com/questions/95036/what-can-cause-a-dns-lookup-to-ignore-a-hosts-file-entry
Both ping server1 and nslookup server1 print the IP address they associate with server1, but ping will use the hosts file (on my system) and nslookup does not.
Now, I have a situation where I alias a lot of ips on a single dev exposed by linux system. this dev is lets say ethX.
Now on ethX I add many ips from a subnet.
Problem:
It appears that the port range is shared for all ips on the ethx. which means:
if I use add an ip x.y.a.b on ethx and use port 5552
now i add an ip y.x.b.a on ethx and try to use 5552 -> this cannot be done
Can anyone confirm this?
addition is done using ip2 utils (ip addr add xxxx dev xxxx) etc.
A TCP connection is identified by the tuple (interface, source address, source port, dest address, dest port), so no, ports are not shared.
What do you mean by use? Do you mean bind()? You should be able to bind() to the same port on different addresses, though you may need to use SO_REUSEADDR, I don't remember the specifics.