IP: Difference between revisions

From Hackepedia
Jump to navigationJump to search
No edit summary
 
m let the macro expand RFC links
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Internet Protocol.  Without it you would not read this.
Internet Protocol.  RFC 791.  It is also called IPv4 (IP version 4) as compared to the new IPv6.  Without IPv4 you would not read this.
 
 
== Obtaining an IP manually or with DHCP ==
 
Often a home connection is provided with a home [[router]] which provides DHCP protocol for connecting workstations or laptops.
 
[[Windows]]:
In Network Configuration under TCP/IP and then Properties, you can choose to either to either request your IP or specify it manually.
 
[[UBO]]:
To obtain a standard IPv4 address, you can either specify it manually, or request one if you have a [[dhcpd]] server on your [[subnet]]. We'll assume in this example that your ethernet interface is "eth0". You should be able to find your interface by typing
$ /sbin/ifconfig
otherwise you will have to find your [[NIC]].
 
To request an IP you will require the application called dhclient, it should be as simple as that
 
# dhclient eth0
Internet Software Consortium DHCP Client 2.0pl5
Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
All rights reserved.
Please contribute if you find this software useful.
For info, please visit http://www.isc.org/dhcp-contrib.html
sit0: unknown hardware address type 776
sit0: unknown hardware address type 776
Listening on LPF/eth0/00:0f:1f:df:4e:39
Sending on  LPF/eth0/00:0f:1f:df:4e:39
Sending on  Socket/fallback/fallback-net
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
receive_packet failed on eth0: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 12
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 17
DHCPOFFER from 192.168.1.1
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.11 -- renewal in 30000 seconds.
 
Now to verify it's up and working:
# ifconfig eth0  | grep inet
inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
 
Looks good. Time you try to [[connect]] somewhere.
 
Although dhcp is the more popular and easier of the two, you can also specify an IP address using ifconfig. You typically will need to know the [[NIC]] and your IP, although you can add subnet and many other options in the [[Manual]] if you want a non-standard configuration.
 
# ifconfig eth0 192.168.1.11
 
should be as simple as that. Now to verify it's working:
 
# ifconfig eth0  | grep inet
inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
 
Excellent! The one difference with setting your IP is that dhcpd usually also defines your default gateway. Your gateway is typically the host of your ISP that your internet traffic will go through. Your gateway or router will be one [[traceroute|hop]] away from you. To set a default gateway of 192.168.1.1 you will do the following. Note that many [[UBO]]s use a different route command, so you will likely use one of the following three:
 
# route add default gw 192.168.1.1
 
# route add default 192.168.1.1
 
# route add default gateway 192.168.1.1
 
but really, you're not going to run a command as [[root]] without reading the [[Manual]] page first to ensure you're using the proper syntax, right?
 
 
Finally, we will check our routing:
 
$ netstat -rn
Kernel IP routing table
Destination    Gateway        Genmask        Flags  MSS Window  irtt Iface
192.168.1.0    0.0.0.0        255.255.255.0  U        0 0          0 eth0
0.0.0.0        192.168.1.1    0.0.0.0        UG        0 0          0 eth0
 
You should be ready to try to [[Connect]] somewhere now.
 
== Exhausting IP addresses ==
 
With 1.5 billion internet users today and more coming the IP address space is getting exhausted.  We have a maximum of 4.5 billion Internet addresses in the 32 bit space of which 0.5 billion are reserved for multicasting and research.  Also, some organizations have entire /8 space for themselves and hardly use it.  We're expected to run scarce on IPv4 address space in the 2010's.  A replacement for IPv4 is already in operation called [[IPv6]].  It offers a lot more address space (128 bits).
 
At the time of this writing it is estimated that there are 687 days left until IPv4 address exhaustion [http://www.potaroo.net/tools/ipv4/index.html Source].

Latest revision as of 07:05, 13 August 2009

Internet Protocol. RFC 791. It is also called IPv4 (IP version 4) as compared to the new IPv6. Without IPv4 you would not read this.


Obtaining an IP manually or with DHCP

Often a home connection is provided with a home router which provides DHCP protocol for connecting workstations or laptops.

Windows: In Network Configuration under TCP/IP and then Properties, you can choose to either to either request your IP or specify it manually.

UBO: To obtain a standard IPv4 address, you can either specify it manually, or request one if you have a dhcpd server on your subnet. We'll assume in this example that your ethernet interface is "eth0". You should be able to find your interface by typing

$ /sbin/ifconfig

otherwise you will have to find your NIC.

To request an IP you will require the application called dhclient, it should be as simple as that

# dhclient eth0
Internet Software Consortium DHCP Client 2.0pl5
Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
All rights reserved.
Please contribute if you find this software useful.
For info, please visit http://www.isc.org/dhcp-contrib.html
sit0: unknown hardware address type 776
sit0: unknown hardware address type 776
Listening on LPF/eth0/00:0f:1f:df:4e:39
Sending on   LPF/eth0/00:0f:1f:df:4e:39
Sending on   Socket/fallback/fallback-net
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
receive_packet failed on eth0: Network is down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 12
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 17
DHCPOFFER from 192.168.1.1
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.11 -- renewal in 30000 seconds.

Now to verify it's up and working:

# ifconfig eth0  | grep inet
inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0

Looks good. Time you try to connect somewhere.

Although dhcp is the more popular and easier of the two, you can also specify an IP address using ifconfig. You typically will need to know the NIC and your IP, although you can add subnet and many other options in the Manual if you want a non-standard configuration.

# ifconfig eth0 192.168.1.11 

should be as simple as that. Now to verify it's working:

# ifconfig eth0  | grep inet
inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0

Excellent! The one difference with setting your IP is that dhcpd usually also defines your default gateway. Your gateway is typically the host of your ISP that your internet traffic will go through. Your gateway or router will be one hop away from you. To set a default gateway of 192.168.1.1 you will do the following. Note that many UBOs use a different route command, so you will likely use one of the following three:

# route add default gw 192.168.1.1
# route add default 192.168.1.1
# route add default gateway 192.168.1.1 

but really, you're not going to run a command as root without reading the Manual page first to ensure you're using the proper syntax, right?


Finally, we will check our routing:

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0

You should be ready to try to Connect somewhere now.

Exhausting IP addresses

With 1.5 billion internet users today and more coming the IP address space is getting exhausted. We have a maximum of 4.5 billion Internet addresses in the 32 bit space of which 0.5 billion are reserved for multicasting and research. Also, some organizations have entire /8 space for themselves and hardly use it. We're expected to run scarce on IPv4 address space in the 2010's. A replacement for IPv4 is already in operation called IPv6. It offers a lot more address space (128 bits).

At the time of this writing it is estimated that there are 687 days left until IPv4 address exhaustion Source.