수. 8월 6th, 2025

Configuring network settings in Linux might seem intimidating, but it’s straightforward with the right tools. Here’s how to manage wired/wireless connections using both command-line and graphical methods.


Method 1: Using nmcli (NetworkManager Command Line)

Best for: Quick changes without GUIs. Works on Ubuntu, Fedora, CentOS, etc.

  1. List network interfaces:

    nmcli device status

    Identify your interface (e.g., eth0 for wired, wlan0 for wireless).

  2. Connect to Wi-Fi:

    nmcli device wifi list              # Scan networks
    nmcli device wifi connect [SSID] password [PASSWORD]
  3. Set static IP (replace eth0, 192.168.1.100, and 8.8.8.8 with your values):

    nmcli con add type ethernet con-name "my-static" ifname eth0 \
    ipv4.addresses 192.168.1.100/24 \
    ipv4.gateway 192.168.1.1 \
    ipv4.dns "8.8.8.8" \
    ipv4.method manual
  4. Restart the connection:

    nmcli con down "my-static" && nmcli con up "my-static"

Method 2: Editing Config Files (Persistent Settings)

Best for: Server environments (Debian/Ubuntu use /etc/network/interfaces; Fedora/CentOS use /etc/sysconfig/network-scripts/).

Example for Debian/Ubuntu (/etc/network/interfaces):

auto eth0  
iface eth0 inet static  
    address 192.168.1.100  
    netmask 255.255.255.0  
    gateway 192.168.1.1  
    dns-nameservers 8.8.8.8  

Apply changes:

sudo systemctl restart networking  

Method 3: GUI Tools (Desktop Users)

  1. Ubuntu:

    • Open Settings > Network.
    • Click the gear icon next to your connection.
    • Configure IPv4/IPv6 under the IPv4 tab (choose “Manual” for static IP).
  2. Fedora/GNOME:

    • Go to Settings > Network > Wired/Wireless > ⚙️ > IPv4.

Essential Verification Commands

  • Check IP address: ip addr show or ifconfig (install with sudo apt install net-tools).
  • Test connectivity: ping google.com.
  • Verify DNS: nslookup example.com.

Troubleshooting Tips

🔹 “Network Unreachable”:

  • Check physical cables/wireless toggle.
  • Restart NetworkManager: sudo systemctl restart NetworkManager.

🔹 DNS Issues:

  • Edit /etc/resolv.conf to add nameserver 8.8.8.8 (temporary fix).

🔹 Interface Not Detected:

  • Verify drivers: lspci | grep -i network.

Final Notes

  • Dynamic (DHCP) vs. Static IP: Use DHCP for automatic IP assignment (default). Use static IPs for servers.
  • Tools: Prefer ip over deprecated ifconfig/route.
  • Distro Differences:
    • Ubuntu 18.04+: Uses netplan (edit /etc/netplan/*.yaml → apply with sudo netplan apply).
    • Arch Linux: See systemd-networkd or NetworkManager docs.

Master these basics, and you’ll confidently manage Linux networks! 🌐🐧

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다