[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: change IP and default route.



Jonathan Colaco wrote:

On Thu, 04 Nov 2004 18:53:15 +0000, Dr. David Kirkby
<drkirkby@medphys.ucl.ac.uk> wrote:
Hi,
   I installed a system on a company network with a fixed IP
(213.78.42.115), but recently bought a small router. The PC will now
have to use the router as the default route, and I will make the IP
private.

The following commands do what I want

# ifconfig eth0 192.168.123.1 netname 255.255.255.0 # set my IP to
192.168.123.1
# route add default gw 192.168.123.254

But how do I set this to happen automatically?  I changed the IP in
/etc/hosts, and had an attempt at changing /etc/gateways, but clearly
not successfully, as the routing does work after a reboot - I need to
type these commands again.


Try this:

edit the file: /etc/network/interfaces

auto eth0
iface eth0 inet static
       address 192.168.123.1
       netmask 255.255.255.0
       network 192.168.123.0
       broadcast 192.168.123.255
       gateway 192.168.123.254


and than: /etc/init.d/network restart

Jonathan Colaço - Jc

Thank you very much for that - and everyone else that replied. I had not seen your post before I see others mentioning /etc/network/interfaces, so edit that. so was not sure what to put for the broadcase, although since the original ended in .255, I went for that too.

Reading the man pages I found the gateway was optional, which rather surprised me. Perhaps the broadcast will get a response from the gateway - I am not sure I must admit.

Anyway, the result it is now works fine, so thanks everyone for their response.

--
Dr. David Kirkby PhD CEng MIEE
Senior Research Fellow
Department of Medical Physics
University College London
11-20 Capper St
London WC1E 6JA
Tel: 020 7679 6406 (direct line)
Tel: 020 7679 6262 (office)





Reply to: