Skip to content
Search

Linux:Network

lastmod 2026-01-19created 2015-04-0234 edits

Notes on Linux network management.

Categories

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-bond0 file. (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

$ cat /sys/class/net/eth0/carrier
## 0이면 Disable, 1이면 Enable

Linux network performance parameters

  • Linux network performance parameters | GeekNews
  • This article provides a comprehensive guide to Linux network performance parameters, focusing on sysctl/network parameters and their role in the Linux network flow.
  • It stresses that people often search for sysctl values that deliver high throughput and low latency, but that this is unrealistic. Newer kernel versions are well tuned by default, and changing the defaults can degrade performance.
  • The article gives a detailed explanation of the Linux network flow, covering both the ingress (incoming data) and egress (outgoing data) processes.
  • It provides a step-by-step guide on checking network performance with the Linux performance analysis tool 'perf'.
  • The article explains various network and sysctl parameters such as Ring Buffer (rx, tx), Interrupt Coalescence (IC), Ingress QDisc, Egress QDisc, and TCP Read and Write Buffers/Queues, and explains their importance for network performance.
  • It provides commands to check, change, and monitor these parameters, giving Linux users a practical guide.
  • The article also mentions the TCP FSM (finite state machine) and congestion algorithms, and provides commands to monitor these aspects.
  • It closes with a list of tools for testing and monitoring networks, such as iperf3, vegeta, and netdata, and provides a comprehensive list of references for further study.
  • The article is a valuable resource for anyone who wants to understand and optimize Linux network performance.

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.

Use nmcli or nmtui.

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

# A의 IP 확인
hostname -I

# B에서 A로 통신
ping A_IP_ADDRESS
ssh username@A_IP_ADDRESS

WiFi Direct (P2P mode)

Uses iw and wpasupplicant. Check driver support:

# WiFi Direct 지원 확인
iw list | grep -A 5 "P2P"

# wpa_supplicant 설치
sudo apt install wpasupplicant

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 통신 가능

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
sysctl net.ipv4.tcp_congestion_control
  • Solution: Choose a congestion control algorithm suited to the environment (e.g., cubic, bbr)
sysctl -w net.ipv4.tcp_congestion_control=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
ethtool -S eth0 | grep -i drop
  • 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
sysctl net.core.wmem_max
sysctl net.core.rmem_max
  • Solution: Increase the socket buffer size
sysctl -w net.core.wmem_max=16777216
sysctl -w net.core.rmem_max=16777216

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
echo 1 > /proc/irq/XX/smp_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
ifconfig eth0 | grep -i mtu
  • Solution: Adjust the MTU size (usually 1500, or adjust to the network environment)
ifconfig eth0 mtu 1500

Kernel network queue management

  • Cause: The kernel's netdev_max_backlog value is low, so large amounts of data are dropped from the transmit queue
  • How to check: Check the current queue size
sysctl net.core.netdev_max_backlog
  • Solution: Increase the queue size
sysctl -w net.core.netdev_max_backlog=5000

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

Tools

  • Packet sniffers (Burp Suite, Zap Proxy, Wireshark), Recon, OSINT, port scanners

See also

Favorite site

References


  1. The number after eht may differ per system. ↩

  2. Linux-network-performance-parameters_README.md.pdf ↩

author Zer0 sitemap