LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Set Static IP (https://www.linuxquestions.org/questions/linux-newbie-8/set-static-ip-832852/)

Quinlan 09-17-2010 11:18 AM

Set Static IP
 
Hello.

I am a student trying to set a static IP for 4 computers in a university laboratory. These computers have been assigned host names (i.e. owl.ceas.wmich.edu) and I need to change the IPs to the static IPs assigned to each of the host names.

I'm having some trouble getting this accomplished, as I have zero experience with this sort of thing. I am using both CentOS 5.5 and Ubuntu 10.04.

The Ubuntu computer has the static IP address: 141.218.142.150

I tried to change the IP using the guide here:
http://www.cyberciti.biz/tips/howto-...iguration.html

It has me adding the following to the /etc/network/interfaces file:

Code:

iface eth0 inet static
address 141.218.142.150
netmask 255.255.255.0
broadcast 141.218.142.255 ?
network 141.218.142.0 ?
gateway 141.218.148.1 ?

I put question marks next to the lines that I am not sure of. I was given only the new IPs in an email. I got the net mask from
'ifconfig eth0'. I tried to look up the broadcast IP, network ID and gateway online, and this is what I came up with.

The next step is to go to /etc/resolv.conf
I am supposed to change my name server, but I don't know what to change it to.

I'm rather lost in this. Any help would be much appreciated.

netmar 09-17-2010 11:39 AM

Actually, that's almost all right.

The netmask is the code to "cover up" part of your address to determine what constitutes a "local" (no router needed) network block. The network is the specification of that same block, and the broadcast is the inverse of the network. The gateway is the address used to connect to anything that is not on the local network block.

In your case, you have a slight problem in that the gateway is set to a IP address outside of your local network, which consists of all 254 addresses starting with 141.218.148. I'm guessing that might be a typo, but if not, it really ought to either be 141.218.142.1, or you need to modify all the other values to give access to the gateway address.

So a solution might look something like this:

iface eth0 inet static
address 141.218.142.150
netmask 255.255.0.0
broadcast 141.218.255.255
network 141.218.0.0
gateway 141.218.148.1

Note that this is the entire address block assigned to Western Michigan (or at least one of them), so unless the whole campus is running on a single LAN/VLAN, it's probably a suboptimal solution.

Unfortunately, all that I can tell you about your nameserver is what's in the public record for wmich.edu, which lists only one nameserver at 141.218.1.104. This should at least give you access to the rest of the internet and most of the campus machines -- I can't really say if it's the one that you're supposed to use.

Ryan10 09-17-2010 11:40 AM

Did you try using the command netconfig...

business_kid 09-17-2010 11:53 AM

So are we, because we don't know fully what you're trying to do. The broadcast line above looks ok, the last 2 you might not need. Beware that red hat (Centos) offers /etc/rc.d/init.d/network as a network connection script which they don't support, and /etc/rc.d/init.d/NetworkManager which they theoretically do support, and each uses different files.

How are you connecting - dhcp? pppoe?
Your provider will supply a dns 1 & 2 for resolv.conf unless you're running your own dns server. If you're going live on the internet, get a serious IT guy to sort the details. It's good to get everything behind a firewall, use NAT, etc. because the internet is a nasty place. My misconfigured router allowed access to port 22 while dhcp had assigned me one particular IP address. My logs began to fill up with hack attempts as scripts tried to log in. My son with a Bsce had a port open also and his vista box was rootkitted :-/.

Quinlan 09-17-2010 12:23 PM

I am trying to have this computer set up with an SSH server, so I can access it remotely. I believe it is a dhcp connection.

netconfig didn't work for the ubuntu machine that I'm on. I googled the command and it looks like it would work on the CentOS system (?).

The professor who's lab I am setting up is pretty good with linux. I'll just ask him since you think that making a mistake with this could potentially be harmful.

Thanks for the help

netmar 09-17-2010 12:26 PM

Oops, sorry, I'm a moron. You did give the hostname, so the two nameservers that I would assign would be the two that seem to be assigned to the department, so your resolv.conf should look like this:

nameserver 141.218.1.100
nameserver 141.218.20.114
nameserver 141.218.1.104

With the third line for "just in case." And Ryan10 is right, as far as the CentOS machines are concerned. You still need all the right addresses, but if you use netconfig, it will ask you for them and save them in the appropriate places.

Come to think of it, you could the NetworkManager applet for the same thing in Ubuntu, if you have it running. It should be the little icon somewhere in the upper right of the screen that says "Network connection" when you mouse-over. Just click on it, click "Configure" and, again, enter the same data.

jmc1987 09-17-2010 12:44 PM

I agree with netmar. Fixing the netmask might fix the issue. Are these server headless (no desktop) If you have the gnome desktop you can go to System > Preferences > Network Connections and configure it there with out touching the command line. Easy way out. But your IPs still have to sync up with each other

Here are some definitions of the address to help you understand

IP: The physical IP of the machine
subnet mask: determines the range of your network or class of the network
broadcast: max IP of the network
network: the start of the network.
Gateway: The IP of the machine that the computer connects through

Somebody feel free to correct me if I wrong or make my terms more simple.

Quinlan 09-17-2010 01:52 PM

I just had an IT guy come down from the university. It looks like it was something on their end. Once I get everything resolved, I'll post it for future reference.

Thanks for the help, guys.

chris_thugs06 09-18-2010 04:11 AM

How to log as as root in freebsd

jmc1987 09-18-2010 04:18 AM

@chris Don't hijack threads. Create a new one. Also google is your best friend.


All times are GMT -5. The time now is 08:58 AM.