Objective
- Know the difference between IPv4 and IPv6 addresses
- Get, set and change the hostname, based on the system we are using
IP Addresses
Are node's addresses used globally and uniquely across the internet. They are registered through ISPs (Internet Service Providers). It is basically a number that indentifies a node in a network.
IPv4
Its a 32 bit address, composed of 4 octets, for example
148.114.252.10
IPv6
Its a 128 bit address, composed of 8 16-bit octet pairs, for example
2003:0db5:6122:0000:1f4f:0000:5529:fe23
In either case, a set of reserved addresses is also included.
IPv4 Address Types
IPv4 address types include
- Unicast
- An address associated with a specific host. It might be something like 140.211.169.4 or 64.254.248.193
- Network
- An address whose host partition is set to all binary zeroes, like 192.168.1.0
- Broadcast
- An address to which each member of a particular network will listen. It will have the host portion set to all 1 bits, for example
- 172.16.255.255
- 148.114.255.255
- 192.168.1.255
- An address to which each member of a particular network will listen. It will have the host portion set to all 1 bits, for example
- Multicast
- An address to which appropriately configured nodes will listen. The address 224.0.0.2 is an example of a multicast address. Only nodes specifically configured to pay attention to a specific multicast address will interpret packets for that multicast group
Special Addresses
- 127.x.x.x
- Reserved for loopback (local system) interface, Generally 127.0.0.1
- 0.0.0.0
- Used by systems that do not yet know their own address. Protocols like DHCP and BOOTP use this address when attempting to communicate with a server
- 255.255.255.255
- Generic broadcast private address, reserved for internal use. These addresses are never assigned or registered to anyone. Generally they are not routable
IPv6 Address Types
- Unicast
- A package is delivered to one interface
- Link local
- Global
- Reserved for documentation
- A package is delivered to one interface
- Multicast
- A packet is delivered to multiple interfaces
- Anycast
- A packet is delivered to the nearest of multiple interfaces (in terms of routing distance)
- IPv4-mapped
- An IPv4 address mapped to IPv6. For example ::FFF:a.b.c.d/96
In addition IPv6 has some special types of addresses such as loopback, which is assigned to the lo interface, as ::1/128
IPv4 Address Classes
Network Class | Highest order octet rante | Notes |
---|---|---|
A | 1-127 | 128 networks, 16, 772, 214 host per network, 127.x.x.x reserved for loopback |
B | 128-191 | 16, 384 networks, 65, 534 hosts per network |
C | 192-223 | 2,097,152 networks, 254 hosts per network |
D | 224-239 | Multicast addresses |
E | 240-254 | Reserved address range |
Netmasks
The netmask is used to determine how much of the address is used to determine the network portion and how much for the host portion. Its also used to determine network and broadcast addresses.
Address Classes and Netmasks
Network Class | Decimal | Hex | Binary |
---|---|---|---|
A | 255.0.0.0 | ff:00:00:00 | 11111111 00000000 00000000 00000000 |
B | 255.255.0.0 | ff:ff:00:00 | 11111111 11111111 00000000 00000000 |
C | 255.255.255.0 | ff:ff:ff:00 | 11111111 11111111 11111111 00000000 |
- Class A
- Use 8 bits for the network portion of the address and 24 bits for the host portion of the address
- Class B
- Use 16 bits for the network and 16 for the host
- Class C
- Use 24 bits for the network and 8 for the host
- Class D
- Are used for multicasting
- Class E
- Are not used
The network address is obtained by anding (logical AND) the IP address with the netmask. We are interested in the network address because they define a local network, all nodes within the same network can see each other.
Example
172.16.2.17 ip address
$255.255.0.0 netmask
------------------
172.6.0.0 network address
Hostname
Its a label used to identify a node in the network
Note: a FQDN = Fully Qualified Domain Name
is a mixture of the domain and the hostname
Example
alejandro.asys.com Domain : asys.com Hostname: alejandro
Getting and Setting the Hostname
Get the hostname
$ hostname
Change the hostname to "andres" in a non persisten fashion
$ sudo hostname andres
Change the hostname in a persisten fashion we need to change the name at
/etc/hostname
or for Red Hat systems
/etc/sysconfig/network
or using the tool
$ hostnamectl --help
Changing the hostname is as simple as
$ sudo hostnamectl set-hostname MYPC