Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-18-2010, 01:01 AM   #1
Registered: Oct 2004
Location: LH
Posts: 610

Rep: Reputation: 31
Problem in adding Default gateway and DNS .

in fedora/redhat system I want to add IP address along with Default Gateway and DNS.
For assigning IP to eth0 i use the command

# ifconfig etho subnet mask upthis remain temporary and when I restart my system it lost the IP address .Well to permanently add IP address in etho I use the file

#cd /etc/sysconfig/network-scripts and then use # vi ifcg-eth0 to add IP address and Network Mask.
How can I add Default Gateway and DNS permanently in ifcg-eth0 file or there is any other file for it ?

Old 06-18-2010, 01:09 AM   #2
Senior Member
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,629

Rep: Reputation: Disabled
Old 06-18-2010, 01:27 AM   #3
Registered: Oct 2004
Location: LH
Posts: 610

Original Poster
Rep: Reputation: 31
not understand.
Old 06-18-2010, 01:34 AM   #4
LQ Newbie
Registered: Jun 2010
Posts: 2

Rep: Reputation: 0

add default gateway in the file ifcfg-eth0 and dns in /etc/resolv.conf

vi ifcg-eth0

GATEWAY=<IP address>

Add the name server in /etc/resolv.conf

nameserver <ipaddress>
Old 06-18-2010, 07:34 AM   #5
Registered: Oct 2004
Location: LH
Posts: 610

Original Poster
Rep: Reputation: 31
well I have three computers in my lab for testing purpose .All three are connected with a small 4 ports switch. the configuration of each computer is

Computer A Fedora
IP address
Subnet Mask
Default Gateway

Computer B Fedora
IP address
Subnet Mask

Computer C Windows xp
IP address
Subnet Mask

In fedora/redhat system I want to add Default Gateway. For that purpose I open # vi /etc/sysconfig/network
and add gateway as following


I save the file and restart the network services. from another computer fedora and windows xp i can ping the computer but when i try to ping the default gateway it say " Destination Host Unreachable/Resquest time out "

Please guide me that how can I fix this issue ? is there any mistake u thing that why Default Gateway not not responding from computer B and C?
Old 06-19-2010, 05:40 PM   #6
Registered: Jul 2004
Location: Alton, IL
Distribution: Linux Mint; Slackware; Ubuntu; Slax
Posts: 172
Blog Entries: 2

Rep: Reputation: 34
Yes, you must have default gateway in order to access the net outside the local net. Run the route command to see what gateways are assigned to which interfaces and for which destination addresses (usually 192.168.1.* will have gateway * because they are 1 hop from that machine and do not require an interface; you should see * addresses having gateway for interface eth0 so that any non-local requests go through that router and out). Do you have a router with an inside ip of If not, setting the gateway address to it will not have any effect.

You should follow the instructions given to configure both the .10 and .20 fedora machines to have their respective addresses and the subnet mask and gateway you have listed, using ifcfg-eth0. I am confused about you saying a fedora/redhat system should have hostname=router... is it acting as the router for the network (should have two network interfaces)?

To test that your network is working, you should ping the other computers on the local network, and then computers on the Internet (like,, If you are not connected to the Internet at all, then default gateway has no effect on a tiny lan with 3 computers connected by a switch with static IP addresses - the ARP table in the switch will accomplish all the traffic routing you need.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding default gateway... imprise Linux - Newbie 2 05-17-2009 02:10 PM
Wierd default Gateway problem Tarn Linux - Networking 1 10-10-2007 11:27 AM
default gateway problem with ndiswrapper and broadcom card gh05t Linux - Wireless Networking 1 02-01-2006 04:03 PM
Automatically adding default gateway when booting enjoyzj Linux - Networking 2 04-13-2004 05:05 PM
Problem pinging default gateway robeb Linux - Networking 6 01-30-2003 01:34 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration