- Write ARTICLE about NETWORKING WITH LINUX
- Understanding Linux Network Interfaces Different versions of Linux may name network interfaces differently (see the callout about how Linux network device names are changing). In general, just about all Linux operating systems will have at least two network interfaces. They are: Basics of Linux Network Administration 46
- Loopback. The loopback (lo) interface will have an IP address of 127.0.0.1, which represents the host itself. Suppose you want to open a web page running on the same Linux server you are on. You could open https://127.0.0.1 in your web browser. That IP address won’t be accessible over the network.
- Ethernet. The ethernet 0 (eth0) interface is typically the connection to the local network. Even if you are running Linux in a virtual machine (VM), you’ll still have an eth0 interface that connects to the physical network interface of the host. Most commonly, you should ensure that eth0 is in an UP state and has an IP address so that you can communicate with the local network and likely over the Internet.
- The Linux command to configure network interfaces/devices/links (whatever term you use) is ip link. In the following example, you can see how ip link (with no other options) shows two different interfaces, their status, and their MAC addresses associated with each one (we’ll talk more about MAC addresses later): david@debian:~$ ip link 1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:50:56:a3:71:f5 brd ff:ff:ff:ff:ff:ff The ip link command is also used to configure network interfaces. For example, you can change the status of interfaces with ip link set [dev] { up | down }. You can also reconfigure network interfaces with a command like ip link set lo mtu 1500. For more information on the ip link command use man ip link.
- MAC Addresses A media access control (MAC) address is the unique identifier assigned to a network interface at layer 2—the Data Link layer—of the OSI Model. A network interface always has a MAC address—often referred to as the hardware address—even if it does not have an IP address. MAC addresses are assigned at the time that a network adapter is manufactured or, if it’s a virtualized network adapter, the time that the adapter is created and appears as six groups of two hexadecimal digits each. On the Ethernet interface, eth0, shown above, the MAC address is also called the link or ether address. In the ip link output above, you can see that the MAC address in this case is 00:50:56:a3:71:f
- IP Addressing They are unique on the same network, every device has at least one, and addresses typically fall somewhere between 1.1.1.1 and 255.255.255.255.
- What are they? IP addresses,I’m going to assume that you already know the basics around TCP/IP, and we’ll focus on how to work with them in Linux. Later in this chapter, we’ll talk about how to configure IP addresses on your Linux machine.
- When it comes to Linux networking tools, there is one that just about everyone has heard of, and that is ping. Ping, which began life as an acronym but now enjoys its status as a full-fledged word, is the most basic network test tool around for testing network reachability. It sends out an Internet Control Message Protocol (ICMP) packet across the network and notifies you whether there is a response. If a host is up and able to communicate on the network, an ICMP response will be returned. If, however, a host is not reachable, you will get a notice that the host was unreachable or timed out (meaning that the ping test failed). Here’s an example of a host that is unreachable:
david@debian:~$ ping -c5 192.168.192.196
PING 192.168.192.196 (192.168.192.196) 56(84) bytes of data.
--- 192.168.192.196 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4018ms
- The traceroute command is useful when you think there may be a network issue, such as a host down along a path or a slow response from one of the intermediary nodes, and you want to find out which node is creating the problem. Here’s an example:
david@debian:~$ traceroute www.apple.com
traceroute to www.apple.com (23.46.180.139), 30 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 0.225 ms 0.273 ms 0.283 ms
2 10.10.0.1 (10.10.0.1) 11.046 ms 11.938 ms 16.645 ms
3 pool.hargray.net (64.202.123.123) 28.169 ms 22.060 ms 21.785 ms
4 10ge14-8.core1.atl1.he.net (216.66.49.77) 22.552 ms 22.391 ms 19.566 ms
5 atx-brdr-01.inet.qwest.net (63.146.26.69) 23.189 ms 21.705 ms 21.952 ms
6 a23-46-180-139.deploy.static.akamaitechnologies.com (23.46.180.139) 21.116 ms 21.365 ms 19.497 ms
- DHCP What if you have dozens, hundreds, or thousands of computers on your network?
- It would be incredibly time-consuming to manually assign IP addresses and to actually track which machines have which IP address. That’s where the dynamic host configuration protocol (DHCP) comes in.
- Basics of Linux Network Administration 52 DHCP is used to obtain an IP address when a host or device first comes on the network.
- DHCP is commonly used for client systems or devices that don’t experience any side effects from a periodically changing IP address. On server systems, administrators either manually configure static IP addresses, or they create what are known as static DHCP reservations that are tied to the MAC address of the network adapter. These static reservations ensure that the network adapter will get the same IP address every time it restart
- Typical DHCP process works:
1. When a computer starts up, it sends a DHCP request out on the network.
2. Assuming a DHCP server is present, a DHCP server responds with the IP address configuration for that device.
3. That IP address is marked as reserved so that it’s not accidentally assigned to some other device.
- DNS Computers that connect to each other using TCP/IP (the most prevalent form of connection protocol) talk with each other using IP addresses; however, it would be really painful to have to remember the IP address of everything you want to connect to. Imagine having to recall the IP address of Google each time you wanted to search the web. Domain name system (DNS) is used to map IP addresses to names. Everyone is familiar with using their web browser, entering a friendly name like google.com or apple.com, and being taken to the company's website without ever having to type an IP address. It’s DNS behind the scenes Basics of Linux Network Administration 54 that is mapping that friendly name to an IP address by doing a DNS lookup. To find out if your Linux host is using DNS, we will be running through some troubleshooting commands, such as dig and nslookup, later.
- That being said, the basics of DNS in Linux are this:
A local file called /etc/hosts is used for the first point of lookup for any host name prior to going out to a DNS server on the network. If the name is found there, no further searches are performed. As the superuser, you have the option to edit the hosts file and configure a static name to IP address mapping.
The /etc/resolv.conf file shows the local domains to be searched and what server names to use for DNS resolution.
When it comes to troubleshooting DNS, you should be aware of the following important tools:
1 dig. The domain Internet roper, or dig, performs verbose DNS lookups and is great for troubleshooting DNS issues. Basics of Linux Network Administration 55
2 getent ahosts. The getent tool with the ahosts option enumerates name service switch files, specifically for host entries.
3 nslookup. The name server lookup, or nslookup, performs a variety of different DNS server lookups: mail server lookups, reverse lookups, and more. It’s commonly used to look up the IP address of a host.
#Internetworking in LINUX
- Layer 2 vs. Layer 3 Internetworking In the OSI model,
- Layer 1 is the physical layer that includes the physical media used to connect the network. Specifications in this area describe cable qualities and the properties of electrical and optical signals used to move bits around. Examples of layer 1 technologies include Gigabit Ethernet on category 5 cable, 100Gigabit Ethernet on parallel single mode fiber, and 802.11 wireless.
- Above that is layer 2, or the data link layer; Ethernet is a broadly deployed layer 2 protocol. Ethernet networking works to encapsulate data and pass that data in the form of frames. Frames leverage the Media Access Control (MAC) addresses that we discussed in Chapter 3. An Ethernet frame includes the MAC address of the destination interface on the target system as well the MAC address of the source interface on the sending system so that the recipient device knows where the frame originated. Every Ethernet device, whether it’s installed in a server, a switch, or a router, has a unique MAC address on their local network. Transparent bridges are layer 2 devices that send all frames received on one port out the other bridge ports, based on knowledge of the frame’s destination MAC address.
- Ethernet switches are multiport network bridges. Multiport network bridges learn of the MAC addresses in the network and intelligently forward frames based on the destination MAC address in the frame.
Layer 2 networking works in one of two ways:
The device has explicit knowledge of a frame’s destination address, and the device sends the frame out on the port where it knows the destination exists.
In the event that the specific destination is unknown, the device falls back to sending the frame to every node in the layer 2 domain via what is known as a broadcast. Understanding Linux Internetworking 67 Definition: Broadcast Domain
- Layer 2 Internetworking on Linux Systems
- Initially, Linux networking was focused on end-node networking and layer 3 internetworking; however, the advent of virtualization and containerization changed that forever. Today’s Linux networking stack has rich layer 2 internetworking functionality and continues to evolve at a rapid pace.
- Bridging What do you do when you have two different Ethernet networks that need connecting? Build a bridge! Bridges have traditionally been dedicated hardware devices, but you can easily create a bridge in Linux. For example, when you have a Linux host that has two or more network interfaces, you can create a bridge to pass traffic between these interfaces. You can add two interfaces to a Linux bridge with ip link set and ip link add using:
david@debian:~$ sudo ip link add br0 type bridge
david@debian:~$ sudo ip link set eth0 master br0
david@debian:~$ sudo ip link set eth1 master br0
Here’s what is happening:
The first command, ip link add, is creating a bridge named br0.
The two ip link set commands add the two Ethernet interfaces, eth0 and eth1, to the new bridge resulting in a connection between these two interfaces.