Conquer the Linux Network Big 3 ๐Ÿ› ๏ธ (IP, Gateway, DNS Configuration Basics)

Hello! When you first connect to a Linux server, one of the first things you need to check is the network settings. It’s like a health indicator ๐Ÿฉบ that tells you if your server is communicating well with the internet world.

However, the numerous numbers and English words appearing in the black terminal can feel like a big wall for beginners. So today, we will learn how to check and briefly manage the three core components of Linux networking: IP address, Gateway, and DNS. Knowing just these three will give you confidence in basic network troubleshooting!

1. Our Home Address – Checking and Temporarily Setting an IP Address ๐Ÿ“ก

An IP address is a server’s unique ‘home address’ in the network world. Other computers need to know this address to find your server.

Check your IP address: ip a

The `ip` command is a modern, powerful, all-purpose tool for managing Linux networks. (Previously, `ifconfig` was used, but `ip` is now the standard!)

ip addr show
# or in abbreviated form
ip a

Executing this command will show you a list of network devices (network cards) like eth0, ens33, along with their assigned IP addresses. The number on the line marked “inet” is your server’s IPv4 address.

Assign a temporary IP address: ip addr add

Sometimes, for network testing or temporary tasks, you might need to assign a different IP address without touching the existing configuration files. In such cases, you can use the command below:

# sudo ip addr add [IP address/subnet] dev [interface name]
sudo ip addr add 10.5.0.1/24 dev eth1
  • 10.5.0.1/24: This is the IP address and subnet mask (CIDR notation) to be assigned. /24 means 255.255.255.0.
  • dev eth1: This is the name of the network device to which the IP will be assigned.

Important! An IP added this way is temporary and will disappear after the server reboots. To set it permanently, you must directly modify the network configuration files.

2. The Door to the Outside – Finding the Default Gateway ๐Ÿšช

The default gateway acts like a ‘main gate’ that your server must pass through to go from its internal network (neighborhood) to the external internet (another city).

To find out where your server’s main gate is, use the `ip route` command.

ip route show
# or in abbreviated form
ip r

In the execution result, look for the line starting with “default via”.

default via 192.168.1.1 dev eth0

The IP address after “via”, which is 192.168.1.1, is this server’s default gateway address. All outbound traffic is sent to this address.

๐Ÿ’ก Tip: Want to extract just the gateway IP address cleanly from the terminal? Try using a pipeline like this!

ip r | grep default | awk '{print $3}'

3. Internet Phonebook – Checking DNS Servers ๐Ÿ“–

We use human-readable domain addresses like google.com, but computers communicate using IP addresses like 172.217.25.142. DNS (Domain Name System) acts as an ‘internet phonebook’ that translates these domain names into IP addresses.

To check which DNS server your server queries, you can look at the `/etc/resolv.conf` file.

cat /etc/resolv.conf

You will see lines starting with “nameserver” in the file content. The IP address listed after it is the address of the DNS server your server uses.

# This file is managed by man:systemd-resolved(8). Do not edit.
nameserver 8.8.8.8
nameserver 8.8.4.4

๐Ÿ’ก Tip: Want to extract just the DNS server IP here too? You can use a combination of `grep` and `awk`.

grep nameserver /etc/resolv.conf | awk '{print $2}'

Wrapping Up

So, today we’ve met the three musketeers of Linux networking:

  • IP Address (ip a): Your server’s address
  • Gateway (ip r): The door to the outside
  • DNS (/etc/resolv.conf): The phonebook for addresses

Knowing the role and checking methods of these three is an excellent first step to not panic when network-related issues arise and to start troubleshooting. Now, go ahead and check your server’s network status yourself!


Tags: Linux, ๋ฆฌ๋ˆ…์Šค, ๋„คํŠธ์›Œํฌ, ์„œ๋ฒ„, IP์ฃผ์†Œ, ๊ฒŒ์ดํŠธ์›จ์ด, DNS, DevOps, ์‹œ์Šคํ…œ์—”์ง€๋‹ˆ์–ด๋ง


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *