LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to change the gateway in a Lan card? (https://www.linuxquestions.org/questions/linux-networking-3/how-to-change-the-gateway-in-a-lan-card-346810/)

saugato 07-26-2005 01:19 AM

How to change the gateway in a Lan card?
 
Hi,

I am having a lot of trouble when i try to change the default gateway ip of a lan card with fixed ip address and gateway already installed.
when i am using netconfig command i am unable to understand which lan card is it as it is not showing the lan card as eth0 or eth1.
plaese suggest a command by which we can change the LAN card (eth0) address and gateway without disturbing the other card eth1.

I would also like to change the DNS ip also. Please suggest a process.

THIS LINUX PC IS IN TEXT MODE!!!:(

roopunix 07-26-2005 01:36 AM

ok let's say you want to change the gateway of eth0 then


#cd /etc/sysconfig/network-scripts
#vi ifcfg-eth0
DEVICE=eth0
IPADDR=192.168.0.x
NETMASK=255.255.255.0
GATEWAY=x.x.x.x

thats it

syl20 07-26-2005 09:39 AM

To configure eth0 : ifconfig eth0 xx.xx.xx.xx up (xx.xx.xx.xx is the IP @ you want for eth0)
to add the default gw on eth0 : route add default gw xx.xx.xx.xx dev eth0 (xx.xx.xx.xx is the IP @ of the gw)
For DNS you have to open /etc/resolv.conf and add :
nameserver xx.xx.xx.xx (xx.xx.xx.xx=IP @ of the DNS)

But with this method, you will have to do that every time the linux box start.

Like roopunix wrote, it's better to fill the appropriate file to avoid to type these commands at every boot time. (the file depends on your distrib)
/etc/rc.d/rc.inet1.conf in a slackware box.
/etc/rc.d/rc.inet1.conf/ifcfg-eth0 for RH and other.

mpeg4codec 07-26-2005 07:37 PM

Can you run ifconfig and paste the results here so we can see what your interfaces' addresses and such are?

To change your DNS server's IP, edit /etc/resolv.conf with your favourite text editor. If you don't know what text editor to use, try nano because it's very easy to use. There should be a line that looks like this:

nameserver x.x.x.x

Change the x.x.x.x to the IP address of your nameserver.

charon79m 07-26-2005 08:44 PM

Your machine should have only ONE default gateway. Having two default gateways, without some extensive configuration, is worthless.

A default gateway is just a way of telling a computer where the door is to get out of a network. That's all.

Why do you think you need a default gateway on eth0 if there is already one on eth1?

MrKnisely


All times are GMT -5. The time now is 01:06 PM.