• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 886
  • Last Modified:

Dns problem

I have RHEL 5.4 server which can not reach any internet server.
I have 2 NIC eth0 the active one and a has a static private IP, and eth1 is not Active nor connected to a switch
I have configured the DNS using my ISP DNS from the Network configuration GUI, then I deactivated, and activated the eth0, but I can not run "nslookup www.yahoo.com", I have restarted the network servcie from the GUI, but  the problem still there plus I have one more error as  below:
#service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  RTNETLINK answers: File exists
Error adding address <ip> for eth0.
                                                           [  OK  ]
Bringing up interface eth1:                                [  OK  ]
# nslookup www.yahoo.com
;; connection timed out; no servers could be reached

Can anyone help me please in that?
0
Ashraf-Hassan
Asked:
Ashraf-Hassan
  • 11
  • 7
  • 2
  • +2
1 Solution
 
Kerem ERSOYPresidentCommented:
Hi,

It seems that you have either have an alias IP set for the same interface or you've forgot to add some directives to your config files.

Will you post the output for these commands:

ls -al /etc/sysconfig/network-scripts

ifconfig

cat /etc/sysconfig/network-scripts/ifcfg-eth0
cat /etc/sysconfig/network-scripts/ifcfg-eth0:0

Cheers,
K.
0
 
farzanjCommented:
Please issue these commands

ip a

And second

cat /etc/resolv.conf
0
 
farzanjCommented:
Also issue this

cat /etc/sysconfig/network-scripts/ifcfg-eth1
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
Ashraf-HassanAuthor Commented:
# ls -al /etc/sysconfig/network-scripts
total 400
drwxr-xr-x 2 root root  4096 Aug  3  2010 .
drwxr-xr-x 9 root root  4096 Mar  7  2010 ..
-rw-r--r-- 5 root root   284 Apr 25 01:08 ifcfg-eth0
-rw-r--r-- 5 root root   239 Apr 25 01:08 ifcfg-eth1
-rw-r--r-- 1 root root   254 Jul  4  2009 ifcfg-lo
lrwxrwxrwx 1 root root    20 Feb 12  2010 ifdown -> ../../../sbin/ifdown
-rwxr-xr-x 1 root root   625 Jul  4  2009 ifdown-bnep
-rwxr-xr-x 1 root root  4573 Jul  4  2009 ifdown-eth
-rwxr-xr-x 1 root root   827 Jul  4  2009 ifdown-ippp
-rwxr-xr-x 1 root root  2159 Jul  4  2009 ifdown-ipsec
-rwxr-xr-x 1 root root  4473 Jul  4  2009 ifdown-ipv6
lrwxrwxrwx 1 root root    11 Feb 12  2010 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x 1 root root  1481 Jul  4  2009 ifdown-post
-rwxr-xr-x 1 root root  1084 Jul  4  2009 ifdown-ppp
-rwxr-xr-x 1 root root   637 Jul  4  2009 ifdown-routes
-rwxr-xr-x 1 root root  1593 Jul  4  2009 ifdown-sit
-rwxr-xr-x 1 root root   913 Jul  4  2009 ifdown-sl
-rwxr-xr-x 1 root root  1074 Jul  4  2009 ifdown-tunnel
lrwxrwxrwx 1 root root    18 Feb 12  2010 ifup -> ../../../sbin/ifup
-rwxr-xr-x 1 root root 13427 Jul  4  2009 ifup-aliases
-rwxr-xr-x 1 root root   859 Jul  4  2009 ifup-bnep
-rwxr-xr-x 1 root root 10798 Jul  4  2009 ifup-eth
-rwxr-xr-x 1 root root 12033 Jul  4  2009 ifup-ippp
-rwxr-xr-x 1 root root  8088 Jul  4  2009 ifup-ipsec
-rwxr-xr-x 1 root root 10853 Jul  4  2009 ifup-ipv6
-rwxr-xr-x 1 root root   823 Jul  4  2009 ifup-ipx
lrwxrwxrwx 1 root root     9 Feb 12  2010 ifup-isdn -> ifup-ippp
-rwxr-xr-x 1 root root   727 Jul  4  2009 ifup-plip
-rwxr-xr-x 1 root root   954 Jul  4  2009 ifup-plusb
-rwxr-xr-x 1 root root  2369 Jul  4  2009 ifup-post
-rwxr-xr-x 1 root root  4298 Jul  4  2009 ifup-ppp
-rwxr-xr-x 1 root root  1707 Jul  4  2009 ifup-routes
-rwxr-xr-x 1 root root  3662 Jul  4  2009 ifup-sit
-rwxr-xr-x 1 root root  1675 Jul  4  2009 ifup-sl
-rwxr-xr-x 1 root root  2078 Jul  4  2009 ifup-tunnel
-rwxr-xr-x 1 root root  3325 Jul  4  2009 ifup-wireless
-rwxr-xr-x 1 root root  5433 Jul  4  2009 init.ipv6-global
-rwxr-xr-x 1 root root  1154 Jul  4  2009 net.hotplug
-rw-r--r-- 1 root root 10474 Jul  4  2009 network-functions
-rw-r--r-- 1 root root 39833 Jul  4  2009 network-functions-ipv6
# ifconfig
eth0      Link encap:Ethernet  HWaddr F4:CE:46:AE:1D:E9
          inet addr:10.10.10.20  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::f6ce:46ff:feae:1de9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:65973 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7111 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6853871 (6.5 MiB)  TX bytes:1793696 (1.7 MiB)
          Interrupt:177

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:280871 errors:0 dropped:0 overruns:0 frame:0
          TX packets:280871 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:79780292 (76.0 MiB)  TX bytes:79780292 (76.0 MiB)
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=none
HWADDR=F4:CE:46:AE:1D:E9
ONBOOT=yes
DHCP_HOSTNAME=ashrafhassan.homeip.net
TYPE=Ethernet
IPADDR=10.10.10.20
NETMASK=255.255.255.0
GATEWAY=10.10.10.254
USERCTL=no
IPV6INIT=no
PEERDNS=yes
# cat /etc/sysconfig/network-scripts/ifcfg-eth0:0
cat: /etc/sysconfig/network-scripts/ifcfg-eth0:0: No such file or directory
# cat /etc/sysconfig/network-scripts/ifcfg-eth1
# Intel Corporation 82572EI Gigabit Ethernet Controller (Copper)
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:23:7d:fd:8e:dc
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
NETMASK=255.255.255.0
IPADDR=10.10.20.20
GATEWAY=10.10.20.1
[root@ashrafhassan ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr F4:CE:46:AE:1D:E9
          inet addr:10.10.10.20  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::f6ce:46ff:feae:1de9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:66051 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7150 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6861989 (6.5 MiB)  TX bytes:1802138 (1.7 MiB)
          Interrupt:177

eth1      Link encap:Ethernet  HWaddr 00:23:7D:FD:8E:DC
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:280999 errors:0 dropped:0 overruns:0 frame:0
          TX packets:280999 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:79813444 (76.1 MiB)  TX bytes:79813444 (76.1 MiB)

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

# cat /etc/resolv.conf
# Generated by NetworkManager


# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
#
0
 
Kerem ERSOYPresidentCommented:
Hi,

I guess your eth0 interface was booting over DHCP and someone converted it to booting from the static address manually. Leaving some DHCP variables in your ifcfg-eth0 file. This is causing the resolv.conf to be reset each time your system reboots. (PEERDNS=yes this paramater is only needed when you use DHCP to boot to reset your resolv.conf and obviously no us in static configs apart from emptying the resolv.conf)

You'll need only one GATEWAY setting in your config files. So I've deleted the one in the ifcfg-eth1.

Another issue is you have assigned the same IP address to both interfaces this is actually causing the error address in use.

After modifying these files don't forget to edit your resolv.conf file and populate it with your domain name and nameserver.

After these restart the networking with this command:

service network restart

Now everything should be fine.

Please modify your ifcfg-eth0 and ifcfg-eth1 as follows:

# Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
HWADDR=F4:CE:46:AE:1D:E9
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.10.10.20
NETMASK=255.255.255.0
GATEWAY=10.10.10.254
USERCTL=no
IPV6INIT=no


# Intel Corporation 82572EI Gigabit Ethernet Controller (Copper)
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:23:7d:fd:8e:dc
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
NETMASK=255.255.255.0
IPADDR=10.10.20.21


/etc/resolv.conf
domain your_domain.com
nameserver your.dns.server.ip


Cheers,
K.



0
 
Kerem ERSOYPresidentCommented:
I've also modified BOOTPROTO=none to static in both config files and removed DHCP_HOSTNAME from ifcfg-eth0 which is obviously not needed anymore.
 
0
 
Ashraf-HassanAuthor Commented:
I modified the NIC as per your advice:
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
HWADDR=F4:CE:46:AE:1D:E9
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.10.10.20
NETMASK=255.255.255.0
GATEWAY=10.10.10.254
USERCTL=no
IPV6INIT=no
# cat /etc/sysconfig/network-scripts/ifcfg-eth1
# Intel Corporation 82572EI Gigabit Ethernet Controller (Copper)
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:23:7d:fd:8e:dc
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
NETMASK=255.255.255.0
IPADDR=10.10.20.21
I modified the resolv.conf many times and I save it, and I confirm that your advised modifications are there, however after restarting the network service I notice that the changes I did for reolv.conf have disappeared:
cat /etc/resolv.conf
# Generated by NetworkManager


# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
#

I did a restart network service but I noticed that:
1- There is an error message while bringing eth0
2- I stil have the problem regarding reahing the intenet:
# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  RTNETLINK answers: File exists
Error adding address 10.10.10.20 for eth0.
                                                           [  OK  ]
Bringing up interface eth1:                                [  OK  ]
# nslookup www.yahoo.com
;; connection timed out; no servers could be reached


What do you advise?
 
0
 
Kerem ERSOYPresidentCommented:
In this case disable the NetworkManager first:

chkconfig NetworkManager off
service NetworkManager stop

Then modify your resolv.conf

then give it another try.

Cheers,
K.
0
 
Ashraf-HassanAuthor Commented:
I stopped the NetworkManager, and I restarted the network service, but still I can not resolve the domain name www.yahoo.com:
# cat /etc/resolv.conf
# Generated by NetworkManager


# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
DNS1=<DNS IP1>
DNS2=<DNS IP2>
DOMAIN=<My Domain Name>
# service NetworkManager status
NetworkManager is stopped
# ifconfig -a
eth0      Link encap:Ethernet  HWaddr F4:CE:46:AE:1D:E9
          inet addr:10.10.10.20  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::f6ce:46ff:feae:1de9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:289 errors:0 dropped:0 overruns:0 frame:0
          TX packets:172 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:31974 (31.2 KiB)  TX bytes:31265 (30.5 KiB)
          Interrupt:177

eth1      Link encap:Ethernet  HWaddr 00:23:7D:FD:8E:DC
          inet addr:10.10.20.21  Bcast:10.10.20.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:610363 errors:0 dropped:0 overruns:0 frame:0
          TX packets:610363 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:159769173 (152.3 MiB)  TX bytes:159769173 (152.3 MiB)

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
# nslookup www.yahoo.com
;; connection timed out; no servers could be reached

# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.10.10.0      0.0.0.0         255.255.255.0   U         0 0          0 eth0
10.10.20.0      0.0.0.0         255.255.255.0   U         0 0          0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth1
0.0.0.0            10.10.10.254    0.0.0.0         UG        0 0          0 eth0


0
 
LinuxNinjaCommented:
You are still missing your DNS entries in your /etc/resolv.conf file.
Something like this would be a good example:
DNS1=4.2.2.2
DNS2=4.2.2.3
DOMAIN=localdomain

This will break any DNS lookups such as the nslookup command you're trying to run.

As for your eth0 error:
Run this to see if there is another address stuck on eth0 along with your preferred address:

# ip addr

If the error persists after a reboot, please let us know.

Also, if eth1 is unplugged and you don't intend to use it, you can change ONBOOT=no for the ifcfg-eth1 file. The other Expert mis-read your IP address config and thought both IP addresses were the same.
0
 
Kerem ERSOYPresidentCommented:
you've stopped the network manager and please be sure that you've completely disabled it using this command:

chkconfig NetworkMonitor off

Though you've stopped the NetworkMonitor service your reslv.conf is still empty apart from commnets. Please edit your /etc/resolv.conf for one last time and populate it with these keywords:

search your.domain.com
nameserver  x.x.x.x


Where x.x.x.x is the IP address of your nameserver.

Then you should be able to resolve IP addresses provided that you have access to the UDP/TCP 53 ports of your nameserver at IP x.x.x.x.

Cheers,
K.
0
 
Kerem ERSOYPresidentCommented:
@LinuxNinja: The syntax you've provided is illegal for the resolv.conf
0
 
Kerem ERSOYPresidentCommented:
and invalid too.
0
 
Ashraf-HassanAuthor Commented:
Hi All,
   My resolv.conf has the same syntax like the commented part (Exactly like LinuxNinja advise)
   What is the correct syntax then?
Thanks,
Ashraf
0
 
Kerem ERSOYPresidentCommented:
The syntax is valid for /etc/sysconfig/network-scripts/itcfg-ethx files.

Yo need to populate your /etc/resolv.conf file as I have indicated in my note Note #35474013
 
Please read the comments fully and apply them. It is the only way we can keep our communication.

Cheers,
K.
0
 
Ashraf-HassanAuthor Commented:
Yes! It is working:
# nslookup www.yahoo.com
Server:         192.16.12.1
Address:       192.16.12.1#53

Non-authoritative answer:
www.yahoo.com   canonical name = fp.wg1.b.yahoo.com.
fp.wg1.b.yahoo.com      canonical name = eu-fp.wa1.b.yahoo.com.
Name:   eu-fp.wa1.b.yahoo.com
Address: 87.248.112.181
Name:   eu-fp.wa1.b.yahoo.com
Address: 87.248.122.122

# cat /etc/resolv.conf
search www.mydomain.com 
nameserver 192.16.12.1


But what will be the format if I want to add another DNS in the resolv.conf?
0
 
upanwarCommented:
Just put the nameserver <IP> in each line to add multiple DNS server.
0
 
LinuxNinjaCommented:
My apologies. I was in a rush and wasn't thinking.
My changes were meant for the ifcfg-eth0 file.
0
 
Ashraf-HassanAuthor Commented:
Something like this:
search  www.mydomain.com
nameserver 192.16.12.1
nameserver 192.16.12.2

?
0
 
upanwarCommented:
Yes
0
 
Kerem ERSOYPresidentCommented:
> # cat /etc/resolv.conf
> search www.mydomain.com
> nameserver 192.16.12.1

Though it hos no problem solving a forign domain please change the search to :

search mydomain.com

It is what to add after you write a non FQDN name such as:

nslookup www

Since your current search path is www.mydomain.com it will complate this non FQDN as follows:

www.www.mydomain.com

This is not correct.

The correct syntax is:


search  www.mydomain.com
nameserver 192.16.12.1
nameserver 192.16.12.2
.
.
.

nameserver 192.168.12.n


0
 
Kerem ERSOYPresidentCommented:
Ooops my bad The correct syntax is:

search  mydomain.com
nameserver 192.16.12.1
nameserver 192.16.12.2
.
.
.

nameserver 192.168.12.n
0
 
Ashraf-HassanAuthor Commented:
Thank you all, and special thanks to you KeremE
0
 
Kerem ERSOYPresidentCommented:
You're welcome.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 11
  • 7
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now