Linux:Network
lastmod 2026-01-19created 2015-04-0234 edits
Notes on Linux network management.
Categories
- Network
- Debian:NetworkConfiguration - Debian network configuration
- Ubuntu:NetworkConfiguration - Ubuntu network configuration
- ArchLinux:Network
- netplan - If you want to set a static IP on Ubuntu, see Netplan#How to set a static IP.
Manually Network Setting
RHEL-based
On RHEL, edit /etc/sysconfig/network-scripts/ifcfg-eth01 as follows. (Assumes IP=192.168.152.231, GateWay=192.168.152.2, DNS=192.168.152.2, MAC=00:21:5e:30:10:9e)
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:21:5e:30:10:9e
NM_CONTROLLED=no
NETMASK=255.255.255.0
GATEWAY=192.168.152.2
DNS1=192.168.152.2
IPADDR=192.168.152.231
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
- If bonding is configured, you must edit the
/etc/sysconfig/network-scripts/ifcfg-bond0file. (Again, the number after bond may differ per system)
Then restart the network with service network restart.
Debian-based
See Debian:NetworkConfiguration.
How to check the ethernet port ENABLE/DISABLE
Linux network performance parameters
How to communicate between two PCs with wireless (Wifi)
Notes on how to communicate between two PCs using only Wifi when there is no router. Explained based on Ubuntu 22.04.
Hotspot method (most stable)
| WARNING |
| A Wi-Fi hotspot lets you share your internet connection by creating a Wi-Fi network that others can connect to. For this, you must be connected to the internet through a path other than Wi-Fi. Turning on the hotspot disconnects that Interface, and internet access over Wi-Fi becomes unavailable. |
Create a Hotspot on laptop A
# NetworkManager 설치 확인
nmcli --version
# Hotspot 생성 (GUI 방식)
nmtui
# 또는 CLI 방식
nmcli device wifi hotspot ifname wlan0 ssid "MyHotspot" password "mypassword123"
Connect from laptop B
nmcli device wifi connect "MyHotspot" password "mypassword123"
# 연결 확인
nmcli device show
ip addr show
Start communicating
WiFi Direct (P2P mode)
Uses iw and wpasupplicant. Check driver support:
Laptop A - Group Owner (GO)
# P2P 인터페이스 생성
sudo ip link add p2p-wlan0 type bridge
sudo wpa_cli -i wlan0 p2p_group_add freq=2412
# 또는 더 간단하게
sudo systemctl start wpa_supplicant
# wpa_cli 대화형 모드
sudo wpa_cli -i wlan0
> p2p_listen
> p2p_group_add
Ad-hoc mode (simple P2P)
Laptop A
# Ad-hoc 네트워크 생성
sudo nmcli con add type wifi ifname wlan0 mode adhoc con-name adhoc ssid "adhoc-net"
sudo nmcli con modify adhoc wifi.channel 6
sudo nmcli con modify adhoc ipv4.method manual ipv4.addresses 192.168.100.1/24
sudo nmcli con up adhoc
# 확인
ifconfig wlan0
Laptop B
# 같은 Ad-hoc 네트워크에 연결
sudo nmcli con add type wifi ifname wlan0 mode adhoc con-name adhoc-join ssid "adhoc-net"
sudo nmcli con modify adhoc-join ipv4.method manual ipv4.addresses 192.168.100.2/24
sudo nmcli con up adhoc-join
# 확인
ping 192.168.100.1
Bluetooth (alternative)
# Bluetooth 페어링
bluetoothctl
> power on
> discoverable on
> agent on
> default-agent
# 다른 노트북에서 검색 및 페어링
# 그 후 serial 통신 가능
Real-world usage example (Hotspot recommended)
Laptop A (server)
# Hotspot 시작
nmcli device wifi hotspot ifname wlan0 ssid "WorkNet" password "Pass123456"
# IP 확인
hostname -I
# 예: 10.42.0.1
# Python 서버 실행
python3 -m http.server 8000
Laptop B (client)
# Hotspot에 연결
nmcli device wifi connect "WorkNet" password "Pass123456"
# A의 IP로 통신
curl http://10.42.0.1:8000
ssh [email protected]
Comparison of methods
| Method | Setup difficulty | Stability | Speed | Compatibility |
| Hotspot | ⭐ Low | ⭐⭐⭐ High | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| WiFi Direct | ⭐⭐⭐ High | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ |
| Ad-hoc | ⭐⭐ Medium | ⭐⭐ Medium | ⭐⭐ | ⭐⭐ |
| Bluetooth | ⭐⭐ Medium | ⭐⭐ | ⭐ Low | ⭐⭐⭐ |
When the network becomes slow on Linux
There can be several causes for the network slowing down while a Linux server transfers large amounts of data. The main causes and their explanations are as follows:
TCP Congestion Control
- Cause: In network congestion, the TCP congestion control algorithm reduces the transmission rate, which can slow things down.
- How to check: Check the congestion control algorithm currently in use
- Solution: Choose a congestion control algorithm suited to the environment (e.g., cubic, bbr)
NIC (Network Interface Card) Buffer Overflow
- Cause: Data transmission can be delayed as the transmit buffer of the network interface card (NIC) fills up.
- How to check: Check the NIC status with ethtool or ifconfig
- Solution: Optimize the NIC driver or upgrade to a high-performance NIC
Socket Send Buffer size limit
- Cause: The application's socket send buffer is too small to handle large amounts of data, causing transmission delays
- How to check: Check the current send buffer size
- Solution: Increase the socket buffer size
Interrupt and CPU Bottleneck
- Cause: Processing large numbers of packets increases CPU load through the NIC's hardware interrupts
- How to check: Check CPU usage with top, htop, or sar
- Solution:
- Use multiple cores by enabling RSS (Receive Side Scaling)
- Adjust IRQ Affinity
Network MTU (Maximum Transmission Unit)
- Cause: If the MTU value is too small or too large, performance degrades during packet fragmentation or reassembly
- How to check: Check the current MTU
- Solution: Adjust the MTU size (usually 1500, or adjust to the network environment)
Kernel network queue management
- Cause: The kernel's
netdev_max_backlogvalue is low, so large amounts of data are dropped from the transmit queue - How to check: Check the current queue size
- Solution: Increase the queue size
Disk I/O bottleneck
- Cause: When the data source is read from disk, slow disk I/O affects the network transfer rate
- How to check: Check I/O performance with iostat or iotop
- Solution: Upgrade to an SSD or enable I/O caching
Network path and QoS (Quality of Service)
- Cause: A bottleneck occurs on the network path between server and client
- How to check: Check the path status with ping and traceroute. Or, for equipment that supports network monitoring protocols such as SNMP, monitor with software such as Nagios.
- Solution: Configure QoS on network equipment or distribute data traffic
Kernel options need optimization
- Cause: The default TCP settings can be inefficient for bulk transfers
- Solution: Adjust the following kernel parameters
sysctl -w net.ipv4.tcp_window_scaling=1
sysctl -w net.ipv4.tcp_moderate_rcvbuf=1
sysctl -w net.core.optmem_max=25165824
Bridge
- Building a Bridge Firewall with Linux
- Building a CentOS5 Linux bridge firewall
- Troubleshooting Ethernet bridging on Linux
- secure :: Linux iptables: testing each server after configuring a Bridge firewall (network)
- Linux Network Bridge
Tools
- Packet sniffers (Burp Suite, Zap Proxy, Wireshark), Recon, OSINT, port scanners
See also
- ifconfig
- Virtual LAN (VLAN)
- OpenVSwitch
- Computer Network (computer networks, direct network connections between PCs, etc...)
- ArchLinux:Network
- Network monitoring
- veth - Linux virtual Ethernet interface
- iperf3
- vegeta
- netdata
Favorite site
- SuSE Linux network configuration - Connecting Linux to a LAN (Local Area Network)
- Doly's CentOS7 lecture 16 6. CentOS Network 1 - Concepts, 2 - Ethernet configuration
- Handbook:AMD64/Networking/Introduction
- Generic Network Configuration Information
- Joinc: Linux IP forwarding
- Joinc: Network Namespace
- Joinc: Bridge
- WiFi/HowToUse - Debian Wiki