Linux - Network Configuration

Part 1: Basic Network Terminology

Before setting up a network or accessing an existing network, it is important to know some key terms that are related to networking. This section explores the terms you should be aware of. Some of the terms are basic and you may already be familiar with them, however others are more advanced.

Host: A host is basically a computer. However, many people have a more limited idea of what a computer is (like a desktop computer or a laptop). In reality, many other devices are also computers, such as cell phones, digital music players and many modern televisions. In networking terms, a host is any device that communicates with another device.

Network: A network is a collection of two or more hosts (computers) that are able to communicate with each other. This communication can be via a wired connection or wireless.

Internet: The Internet is an example of a network. It consists of a publically accessible network that connects millions of hosts throughout the world. Many people use the Internet to surf web pages and send/receive email, but the Internet has many additional capabilities besides these activities.

Wi-Fi: The term Wi-Fi refers to wireless networks.

Server: A host that provides a service to another host or client is called a server. For example, a web server stores, processes and delivers web pages. An email server receives incoming mail and delivers outgoing mail.

Service: A feature being provided from a host is a service. An example of a service would be when a host provides web pages to another host.

Client: A client is a host that is accessing a server. When you are working on a computer surfing the Internet, you are considered to be on a client host.

Router: Also called a gateway, a router is a machine that connects hosts from one network to another network. For example, if you work in an office environment, the computers within the company can all communicate via thelocal network created by the administrators. To access the Internet, the computers would have to communicate with a router that would be used to forward network communications to the Internet. Typically when you communicate on a large network (like the Internet), there are several routers that are used before your communication reaches its final destination.

The following diagram provides a visual reference for several of the terms discussed above:

1. Networking Features Terminology

In addition to the networking terms discussed in the last section, there are some additional terms that you should be aware of. These terms focus more on the different types of networking services that are commonly used as well as some of the techniques that are used to communicate between machines.

Network packet: A network packet is used to send network communication between hosts. By breaking down communication into smaller chunks (packets), the data delivery method is much more efficient.

IP address: An Internet Protocol (IP) address is a unique number assigned to a host on a network. Hosts use these numbers to "address" network communication. More discussion on IP addresses will occur later in this chapter.

Network mask: Also called a netmask or mask, a network mask is a number system that can be used to define which IP addresses are considered to be within a single network. Because of how routers perform their functions, networks have to be clearly defined.

Hostname: Each host on a network could have its own hostname. This makes it easier for humans to address network packets to another host because names are easier for humans to remember than numbers. Hostnames are translated into IP addresses before the network packet is sent on the network.

DHCP: Hosts can be assigned hostnames, IP addresses and other network-related information by a DHCP (Dynamic Host Configuration Protocol) server. In the world of computers, a protocol is a well-defined set of rules. DHCP defines how network information is assigned to client hosts and the DHCP server is the machine that provides this information. While setting up a DHCP server is beyond the scope of this chapter, you will see how to configure a DHCP client machine later in this chapter.

DNS: As mentioned previously, hostnames are translated into IP addresses, prior to the network packet being sent on the network. This means that your host needs to know the IP address of all of the other hosts that you are communicating with. When working on a large network (like the Internet), this can pose a challenge as there are so many hosts. A DNS (Domain Name Server) server provides the service of translating domain names into IP addresses. While setting up a DNS server is beyond the scope of this chapter, you will see how to configure a DNS client machine later in this chapter.

Ethernet: In a wired network environment, Ethernet is the most common way to physically connect the hosts into a network. Ethernet cables are connected to network cards that support Ethernet connections. Ethernet cables and devices (such as routers) are specifically designed to support different speeds of communications, the lowest being 10 Mbps (10 Megabits per second) and the highest being 100 Gbps (100 gigabits per second). The most common speeds are 100 Mbps and 1 Gbps.

TCP/IP: The Transmission Control Protocol/Internet Protocol (TCP/IP) is a fancy name for a collection of protocols (remember, protocol = set of rules) that are used to define how network communication should take place between hosts. While it isn‘t the only collection of protocols used to define network communication, it is the most often utilized one. As an example, TCP/IP includes the definition of how IP addresses and network masks work.

2. IP Addresses

As previously mentioned, hosts "address" network packets by using the IP address of the destination machine. The network packet also includes a "return address", the IP address of the sending machine.

There are, in fact, two different types of IP addresses: IPv4 and IPv6. To understand why there are two different types, you need to understand a brief bit of IP addressing history.

For many years, the IP addressing technique that was used by all computers was IPv4 (IP version 4). In an IPv4 address, a total of four 8-bit (8-bit = numbers from 0 to 255) numbers are used to define the address. For example:192.168.10.120. Note, this is considered a 32-bit address (4 x 8-bit = 32).

Each host on the Internet must have a unique IP address. In an IPv4 environment, there is a technical limit of about 4.3 billion IP addresses. However, many of these IP addresses are not really useable for various reasons. Also, IP addresses have been assigned to organizations that haven‘t fully made use of all of the IP addresses they had available.

While it seems like there should be plenty of IP addresses to go around, various factors (the increasing number of hosts on the Internet, reserved private IP addresses, etc.) led to a problem: The Internet started running out of IP addresses.

This, in part, encouraged the development of IPv6. IPv6 was officially "created" in 1998. In an IPv6 network the addresses are much larger, 128-bit addresses that look like this: 2001:0db8:85a3:0042:1000:8a2e:0370:7334. Essentially this provides for a much larger address pool, so large that running out of addresses any time in the near future is very unlikely.

It is important to note the difference between IPv4 and IPv6 isn‘t just "more IP addresses". IPv6 has many other advanced features that address some of IPv4‘s limitations, including better speed, more advanced package management and more efficient data transportation.

Considering all the advantages, you would think that by now all hosts would be using IPv6. This isn‘t the case at all. The majority of network-attached devices in the world still use IPv4 (something like 98-99% of all devices). So, why hasn‘t the world embraced the superior technology of IPv6?

There are primarily two reasons:

  1. The invention of NAT: Invented to overcome the possibility of running out of IP addresses in an IPv4 environment, Net Address Translation (NAT) used a technique to provide more hosts access to the Internet. In a nutshell, a group of hosts are placed into a private network with no direct access to the Internet; a special router provides Internet access and only this one router needs an IP address to communicate on the Internet. In other words, a group of hosts share a single IP address, meaning a lot more computers can attach to the Internet. This feature means the need to move to IPv6 is less critical then before the invention of NAT.
  2. Porting issuesPorting is switching over from one technology to another. IPv6 has a lot of great new features, but all of the hosts need to be able to utilize these features. Getting everyone on the Internet (or even just some) to make these changes poses a challenge.

Most experts agree that IPv6 will eventually replace IPv4, so understanding the basics of both is important for those who work in the IT industry.

Part 2: Configure Network Devices

When you are configuring network devices, there are two initial questions that you need to ask:

  1. Wired or wireless? Configuring a wireless device will be slightly different than a wired device because of some of the additional features typically found on wireless devices (such as security).
  2. DHCP or static address? Recall that a DHCP server provides network information, such as your IP address and subnet mask. If you don‘t make use of a DHCP server, then you will need to manually provide this information to your host. This is called using a static IP address.

Generally speaking, a desktop machine will use wired network, while a laptop will use wireless. Normally a wired machine uses a static IP address, but these can also often be assigned via a DHCP server. In almost all cases, wireless machines use DHCP since they are almost always mobile and attached to different networks.

1. Configure the Network Using GUI

2. Configuring the Network Using Configuration Files

There will be times when no GUI-based tool will be available. In those cases, it is helpful to know the configuration files that are used to store and modify network data.

These files can vary depending on the distribution that you are working on. The following examples are provided for CENTOS systems.

2.1 Pimary IPv4 Configuration File

The primary configuration file for an IPv4 network interface is the/etc/sysconfig/network-scripts/ifcfg-eth0 file. The following demonstrates what this file looks like when configured for a static IP address:

If the device was configured to be a DHCP client, then the IPADDRGATEWAYand DNS1 values would not be set. Additionally, the BOOTPROTO value would be set to "dhcp".

[[email protected] ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eno1
HWADDR=44:37:E6:C8:AF:CF
TYPE=Ethernet
BOOTPROTO="none"
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno1
UUID=98971396-983e-47a2-9ee7-a8706eec59ff
ONBOOT=yes
IPADDR="192.168.1.100"
PREFIX="24"
GATEWAY="192.168.1.1"
DNS1="218.2.135.1"
DNS2="210.29.144.1"
时间: 2024-10-23 19:18:02

Linux - Network Configuration的相关文章

Lesson5 -Linux Network Configuration

basic tasks 1.ifconfig     show ip,networkcard infomation    eth0 2.sudo dhclient      release renew IP configuration 3.sudo /etc/init.d/neworking restart             restart networking servers when you change severs configuration Configuration files

Docker Network Configuration 高级网络配置

Network Configuration TL;DR When Docker starts, it creates a virtual interface named docker0 on the host machine. It randomly chooses an address and subnet from the private range defined by RFC 1918 that are not in use on the host machine, and assign

ubuntu开机出现waiting for network configuration

ubuntu启动时,出现waiting for network configuration,waiting up to 60 more seconds for network configuration等,进入桌面后网络图标也不见了 解决方法,首先在 /etc/network/interfaces 文件里面无关的都删去,留下lo这个 然后再到/etc/init/failsafe.conf文件里将sleep59改成5或10,sleep50意思是等待59秒

setup界面的network configuration 进不去的原因

setup界面的network configuration 进不去的原因 这个问题在百度上搜了好久都没搜到能解决的答案,最后还是自己琢磨出来的. 目前我遇进不去的原因是,因为在刚装好系统(装的是最小化的)后直接暴力装的system-config-network-tui,导致缺少依赖包,造成了点不进去. 解决办法: rpm-qa | grep 'system-config-network-tui' 查看所有安装包并过滤出网络安装包            rpm-e system-config-ne

解决 Ubuntu 开机 Waiting for 60 seconds more for network configuration

sudo vim /etc/network/interfaces, 将该文件的内容修改为如下:(也就是说删掉其他的什么auto eth0.auto wlan0) auto lo iface lo inet loopback 解决 Ubuntu 开机 Waiting for 60 seconds more for network configuration,码迷,mamicode.com 解决 Ubuntu 开机 Waiting for 60 seconds more for network co

Netruon 理解(12):使用 Linux bridge 将 Linux network namespace 连接外网

学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GRE/VxLAN 虚拟网络 (4)Neutron OVS OpenFlow 流表 和 L2 Population (5)Neutron DHCP Agent (6)Neutron L3 Agent (7)Neutron LBaas (8)Neutron Security Group (9)Neutro

Linux network namespaces

介绍OpenStack neutron使用Linux网络命名空间来避免物理网络和虚拟网络间的冲突,或者不同虚拟网络间的冲突. 网络命名空间就是一个独立的网络协议栈,它有自己的网络接口,路由,以及防火墙规则. 网络命名空间通常是位于目录/var/run/netns/下的文件描述符. 例如,使用ip netns add命令创建一个命名空间: ip netns add bule 查看目录/var/run/netns/: $ ls /var/run/netns/ blue 网络命名空间常用于虚拟化中.因

Linux Network IO Model Learning

目录 0. 引言 1. IO机制简介 2. 阻塞式IO模型(blocking IO model) 3. 非阻塞式IO模型(noblocking IO model) 4. IO复用式IO模型(IO multiplexing model) 5. 信号驱动式IO模型(signal-driven IO model) 6. 异步IO式IO模型(asynchronous IO model) 7. Linux下IO技术简介 8. IO模型编程举例 0. 引言 Linux将所有外部设备都看做一个文件来进行操作.

Netruon 理解(11):使用 NAT 将 Linux network namespace 连接外网

学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GRE/VxLAN 虚拟网络 (4)Neutron OVS OpenFlow 流表 和 L2 Population (5)Neutron DHCP Agent (6)Neutron L3 Agent (7)Neutron LBaas (8)Neutron Security Group (9)Neutro