Solved

Providing static ip address

Posted on 2004-04-14
6
2,315 Views
Last Modified: 2010-03-18

 Hi,

    I have set the dhcp to provide the ip address to my linux machine while installing. Now that i want to give the ip address manually. How can i acheive it.

Many Thanks.
0
Comment
Question by:mkcharan
6 Comments
 
LVL 17

Expert Comment

by:owensleftfoot
ID: 10822885
What distro are you using?
0
 
LVL 14

Accepted Solution

by:
kronostm earned 50 total points
ID: 10823831
basically that's all you have to do :
ifconfig eth0 xxx.yyy.zzz.ttt netmask 255.255.255.0 up
where xxx.yyy.zzz.ttt is the desired IP address and I assumed a 255.255.255.0 network mask, but you can change it to whatever fits your network.
0
 
LVL 5

Expert Comment

by:brabard
ID: 10835106
Basically kronostm is right , typing ifconfig command will change your ip address and netmask , but you have to obtain at least 3 things via dhcp to access Internet - ip address/mask , default gw & dns server .
You can do it manually by 3 steps :
1. ifconfig as kronostm said ;
2. route del defaul (it is just in case the new address is in the same network but in other subnetwork)
   route add default gw xxx.yyy.zzz.ttz
3. Edit your /etc/resolv.conf with putting at the top row "nameserver www.xxx.yyy.zzz"

But if you want to save the static setting after reboot , you have to edin config files , that are different , depending to your Linux distibution .
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:mkcharan
ID: 10851362


 Hi,

      Thanks for the answers. I was able to change my ip address as desired. But as brabard told it changes after the reboot. so what are the files that i have to edit to keep the ip address permanent.
I have Redhat Linux 9 distribution. And if you need further details i am ready to provide.

 Many Thanks & Regards
 Murugan Kalicharan S
0
 
LVL 1

Expert Comment

by:terabiteau
ID: 10992611
You will need to modify this file ...

/etc/sysconfig/network-scripts/ifcfg-eth0

and it should look like this ...

DEVICE=eth0
IPADDR=x.x.x.x
NETMASK=255.255.255.0
ONBOOT=yes

Note that the NETMASK must match what ever your ISP specifies - I have just shown the most common form.

Good luck!
0
 
LVL 1

Expert Comment

by:JohnnyLingo
ID: 10998262
Don't forget to set a default gateway with a "GATEWAY=" line, either in this file or in /etc/sysconfig/network.  And set the DNS domain name and servers in /etc/resolv.conf, like

search mydomain.com
nameserver 1.2.3.4
nameserver 1.2.4.9

Also, if this is just a workstation or non-critical server why not continue to use DHCP with a reserved IP address?  Makes your life much easier, since if the default GW or DNS servers ever change you will pick up the settings automatically.  This is strongly recommend if you are in a predominately Windows 2000 network, since the hostname will get registered in DNS.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question