Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two servers both running Scientific Linux 6 on the same network. Since I want SSH access to both of them, I want to give them both static IPs so I can setup port forwarding and not worry how my router assigns local IPs. I found that I need to edit the configuration file /etc/network-scripts/ifcng-eth0, however that file does not exist. The network card works fine, and I am able to ssh as long as I access the router and find the local ip.

Can I simply make my own configuration file, or did I miss some step in configuring the system that I need to complete?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

It should be enough to simply edit /etc/hosts. So, assuming your server is called server1 and you want to give it the IP 10.9.8.7, edit /etc/hosts as root and add this line:

10.9.8.7    server1

Then restart the networking service or your machine and you should have a static IP.

As a general note, usually when a file you are supposed to edit on Linux to configure something or other is absent, it is a safe bet that you can simply create it and add the specified lines. Not always, mind you, but often.

If that does not work, it may be necessary to create the eth0 configuration file. Follow the instructions here to do so.

share|improve this answer
    
I added a line at the top of the file that included the network IP i wanted to use and my full host name. I rebooted the computer, however it did not change the IP that got assigned to it by the router. –  Godric Seer Aug 30 '12 at 1:23
    
@GodricSeer Hmm, ok, that seems to be enough for my debian. Try following the suggestions on this page and just create the /etc/sysconfig/network-scripts/ifcfg-eth0 file. Also, if you have gnome installed, you can do it through its network manager GUI. –  terdon Aug 30 '12 at 1:33
    
I followed the directions, adding the file. upon reboot it does not change the ip given by the router. I attempted service network restart, and it failed, saying that the device does not appear to be present. –  Godric Seer Aug 30 '12 at 1:57
    
just an FYI to anyone who finds this later, don't put spaces around the equal signs in the configuration file. It throws very cryptic errors. –  Godric Seer Aug 30 '12 at 2:14
    
Glad you solved it @GodricSeer :) –  terdon Aug 30 '12 at 2:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.