LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Staticly Assign IP (https://www.linuxquestions.org/questions/debian-26/staticly-assign-ip-432761/)

carlosinfl 04-07-2006 02:03 PM

Staticly Assign IP
 
Where in Debian can I staticly set an IP? I did a search and the board and found /etc/network/interface and there I have this text file...

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping eth0
script grep
map eth0

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp


I am not sure how to add my static IP, gateway and mask.

manishsingh4u 04-07-2006 02:19 PM

Try this in your /etc/network/interfaces. This must help
Code:

auto eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1


carlosinfl 04-07-2006 03:57 PM

Thanks makes sense however my info is as follows but I am not sure what my network and broadcast Ip would be...

Code:

auto eth0
iface eth0 inet static
address 10.1.1.204
netmask 255.255.0.0
network 10.1.0.0 < ------?
broadcast 10.1.255.255 <-----?
gateway 10.1.1.1


Dead Parrot 04-07-2006 07:02 PM

You can simply omit the network and broadcast lines. Most likely you won't need them.

pljvaldez 04-07-2006 07:13 PM

If you leave them, I believe yours should read
Quote:

Originally Posted by Carlwill
Code:

auto eth0
iface eth0 inet static
address 10.1.1.204
netmask 255.255.0.0
network 10.1.1.0 < ------?
broadcast 10.1.1.255 <-----?
gateway 10.1.1.1


because they all need to be on the same subnet (10.1.1.xxx)

rickh 04-07-2006 07:25 PM

I don't really understand this issue, so maybe I'm way off base, but my router allows me to match the MAC address of any computer connected to it with whatever IP address I want that computer to have. Isn't that the same thing?

For that matter, I've noticed that without me doing anything, the router always assigns each PC the same IP whenever it connects even if I don't specify that it should.

pljvaldez 04-07-2006 07:49 PM

Sort of. What your router is allowing is called "static DHCP". You enter the MAC and assign an IP. But all the clients are still using DHCP (i.e. they're polling the router asking for an address).

Right now it might appear that all the machines are always getting the same address. But if you turned all the machines off until the lease expired (mine defaults to 24 hours) and then started the computers up in a different order, the machines would get different IP's because they're assigned by the router on a first come first serve basis (unless you're using static dhcp).

Now it's also possible to make the client static. That's what is happening here. This is useful if the router doesn't have static dhcp capability, but you always want you machine at the same IP (for example if you're forwarding ports to a server on your internal network and don't want the routing table messed up if you reboot and it gets assigned a different address). This is mostly a problem on large networks because if you have hundreds of machines, some of them being shut off at different times (like over a weekend) and then turned on in a different order, you could mess up your routing table if your server went down for the weekend also...

Tons of Fun 04-08-2006 04:56 AM

I am not sure that the network address and broadcast address is correct? Looking at the subnet mask of 255.255.0.0, it seems he would want a network of 10.1.0.0 and a broadcast of 10.1.0.255. He is using a class B subnet with a class A private address, that is where I got my calculations. Now I am by no way a TCP guru, so if I'm off base, please let me know because I am always trying to learn more, but this one seemed pretty straight forward.
I also think Dead Parrot is correct, I don't think they are even required in the interfaces file as those are normally used for routers. However, if they are in there, they need to be correct.

:study:


All times are GMT -5. The time now is 03:46 PM.