Configure static IP for Linux OS

Dear Experts,

How do I configure the static IP Address of a linux server?

Is it?

Method 1

Ifconfig eth0 192.168.1.13 netmask 255.255.255.0 up
Gateway
Route add Default gw 192.168.1.254
DNS
Echo “nameserver 8.8.8.8”> /etc/resolv.conf

Method 2

Sudo ifconfig eth0 192.168.1.13 netmask 255.255.255.0
Sudo route add Default gw 192.168.1.254 eth0

Are there other methods?

I just want to cover all the possibilities so I won't get stuck if any of the methods do not work.

I also know that only the root can change the IP Address.
LVL 1
Anonymous KHIT EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
Which Linux system?
There are commonly network config tools
/etc/sysconfig/network


Knowing which system you are on can clarify..

Usually during the install, you are promoted for all the information including network.....
0
Pushpakumara MahagamageVPCommented:
What is the linux flaver I mean Redhat, Debian, FreeBSD etc,

you can edit network file #

https://www.swiftstack.com/docs/install/configure_networking.html

you can use the GUI also ----

http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html

Route you have to add separately ---- static / persistent

https://www.cyberciti.biz/faq/linux-route-add/
0
Anonymous KHIT EngineerAuthor Commented:
Sorry it is a Redhat Linux
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Prabhin MPEngineer-TechOPSCommented:
0
Anonymous KHIT EngineerAuthor Commented:
I did not know that I have to add broadcast address.
0
Prabhin MPEngineer-TechOPSCommented:
dont configure broadcast address, configure only IP address , netmask , gateway and DNS.
0
Pushpakumara MahagamageVPCommented:
Hi Kevin,

What is the perfect method to apply network settings, I mean linux command, edit network file or use GUI.
0
Pushpakumara MahagamageVPCommented:
Sry,

I'm asking you. Which method you like to use.
0
AlanConsultantCommented:
Hi Pushpakumara Mahagamage,

Personally, I prefer using the command line.

Since I am working on clients' servers / machines, I document everything I do as a basic professional requirement.  If I use the command line for everything possible, then it is really easy to document, and also to script a new setup / machine to be exactly the same if I ever need to (just run a script with all the commands).

It is also much easier to look through the script and see if, over time, you can consolidate or remove lines where configuration has changed.

For example, maybe a machine started out with one static IP, and then got a different static IP.  If I ran all the commands on a new setup it would still correctly get the new Static IP (assuming that is what we want), but I could also remove the earlier assignment and reduce the number of lines / commands / clutter.


Hope that helps,

Alan.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arnoldCommented:
See if you have system-config-network-tui
Before running, make sure you have the ip, netmask, and default gateway along with at least one nameserver ip.
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Probably good to ask if you're doing this on a local system or server which you've leased from a hosting company.

If you've leased a machine from a hosting company, they should provide you with network setup + any alteration is unwise.

So, just to be clear make an update as to what type of machine this is - local machine or hosting company machine.
0
Anonymous KHIT EngineerAuthor Commented:
It is a client's server but it has a GUI, my colleague saw it. Another issue is that it is also mirroring the database to a secondary server, virtualising it is going to be an issue.
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
I'll ask my question differently. Update your question with where this machine resides physically.

Can you walk to it + touch it or is it deployed on the net somewhere at a provisioning or hosting company?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.