Giriş: Linux Router Kimi
Linux serveri şəbəkədə düzgün yerləşdirmək üçün CCNA biliyinizin hamısı işə yarayır: IP, maska, gateway, marşrut, VLAN, NAT.
Fərq ondadır ki, burada əmrlər ip, ss, nmcli/netplan və nftables-dır.
Köhnə ifconfig, netstat, route əmrləri (net-tools) artıq defolt quraşdırılmır.
1. ip Əmri
ip -br a # qısa: interfeys, vəziyyət, IP-lər
ip -br link # MAC və link vəziyyəti
ip route # routing cədvəli
ip route get 8.8.8.8 # bu paket hansı yolla gedəcək?
ip neigh # ARP cədvəli
# Müvəqqəti dəyişikliklər (reboot-da itir)
ip addr add 10.0.20.15/24 dev eth1
ip link set eth1 up
ip route add 10.50.0.0/16 via 10.0.20.1
ip link add link eth0 name eth0.30 type vlan id 30 # 802.1Q subinterfeys
| Köhnə (net-tools) | Yeni (iproute2) |
|---|---|
ifconfig | ip a |
route -n | ip r |
arp -a | ip neigh |
netstat -tulpn | ss -tulpn |
2. Daimi Konfiqurasiya
# /etc/netplan/01-static.yaml
network:
version: 2
ethernets:
eth0:
addresses: [192.168.10.20/24]
routes:
- to: default
via: 192.168.10.1
nameservers:
addresses: [192.168.10.5, 1.1.1.1]
search: [lab.local]
vlans:
eth0.30:
id: 30
link: eth0
addresses: [10.30.0.20/24]
netplan try # 120 saniyə ərzində təsdiq etməsəniz, əvvəlki vəziyyətə qayıdır
netplan apply
nmcli device status
nmcli con show
nmcli con mod eth0 ipv4.method manual ipv4.addresses 192.168.10.20/24 \
ipv4.gateway 192.168.10.1 ipv4.dns "192.168.10.5 1.1.1.1" ipv4.dns-search lab.local
nmcli con up eth0
nmcli con add type vlan con-name vlan30 dev eth0 id 30 ipv4.method manual ipv4.addresses 10.30.0.20/24
nmtui # mətn əsaslı menyu
Uzaq serverdə şəbəkə dəyişikliyi etmədən əvvəl konsol girişiniz (iDRAC/iLO, VM konsolu) olduğuna əmin olun və ya netplan try kimi avtomatik geri qaytarma istifadə edin.
3. DNS, Hostname və Vaxt
hostnamectl set-hostname web01.lab.local
cat /etc/hosts # lokal ad cədvəli — DNS-dən əvvəl yoxlanır
resolvectl status # systemd-resolved istifadə edirsə
cat /etc/resolv.conf
dig +short portal.lab.local
dig @192.168.10.5 lab.local MX
getent hosts db01 # sistemin faktiki ad həlli (hosts + DNS)
timedatectl set-timezone Asia/Baku
chronyc sources -v # NTP sinxronizasiyası
4. Firewall
ufw default deny incoming
ufw default allow outgoing
ufw allow from 10.0.0.0/24 to any port 22 proto tcp
ufw allow 443/tcp
ufw enable
ufw status numbered
firewall-cmd --get-active-zones
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.0.0.0/24 service name=ssh accept'
firewall-cmd --permanent --remove-service=ssh # hamı üçün ssh-ı bağla
firewall-cmd --reload
firewall-cmd --list-all
# /etc/nftables.conf
table inet filter {
chain input {
type filter hook input priority 0; policy drop;
ct state established,related accept
iif lo accept
ip saddr 10.0.0.0/24 tcp dport 22 accept
tcp dport { 80, 443 } accept
icmp type echo-request limit rate 5/second accept
}
}
nft -c -f /etc/nftables.conf # yoxla
nft -f /etc/nftables.conf # tətbiq et
nft list ruleset
5. Diaqnostika
ss -tulpn # dinləyən portlar və proseslər
ss -tn state established '( dport = :443 )'
curl -sv https://portal.lab.local -o /dev/null # TLS və HTTP mərhələləri
nc -zv db01 5432 # port açıqdırmı
mtr -rwc 50 8.8.8.8 # hər hop-da itki və gecikmə
tcpdump -ni eth0 host 10.0.20.50 and port 53 # DNS paketləri
tcpdump -ni any -w /tmp/cap.pcap port 443 # Wireshark üçün fayla
ethtool eth0 # sürət, duplex, link
ethtool -S eth0 | grep -i err # NIC xəta sayğacları
Ardıcıllıq aşağıdan yuxarı: link (ip link, ethtool) → IP/gateway (ip a, ping gateway) → routing (ip route get) → DNS (dig) → port/firewall (ss, nc) → tətbiq (curl, log-lar).