Differenze tra le versioni di "Net-HOWTO"

Da GolemWiki.
Jump to navigation Jump to search
Riga 111: Riga 111:
  
 
==Setup LAN Interfaces==
 
==Setup LAN Interfaces==
# ip addr
+
===Predictable Network Interface Names===
# ip addr add 192.168.0.2/24 dev enp6s0
+
Starting with v197 systemd assign fixed and predictable network interface names for all local network devices instead of the traditional ''eth0, ''eth1'', ''wlan0'' which may change after a reboot post kernel update. This feature simplify the system management and fix potential security implications e.g., changing firewall rules.
# ip route add default via 192.168.0.1
 
  
 +
These names are based on hardware firmware/topology/location information and they stay fixed even if hardware is added or removed.
  
https://wiki.golem.linux.it/Appunti_Arch_Linux#Networking
+
Prefix Description
 +
en Ethernet
 +
ib InfiniBand
 +
sl Serial line IP (slip)
 +
wl Wireless local area network (WLAN)
 +
ww Wireless wide area network (WWAN)
  
Elencare gli indirizzi IP:
+
eth0 could be renamed enp6s0: en (ethernet) + p6  (bus 6) + s0 (slot 0)
  
# ip addr
+
=== Configuring LAN interfaces ===
 +
The following commands activates the enp6s0 interface with the IP 192.168.0.2, in the subnet 192.168.0.1-255, using the router-gateway 192.168.0.1
  
Mostra le informazioni di una specifica interfaccia di rete
+
# ip addr add 192.168.0.2/24 dev enp6s0
 +
# ip route add default via 192.168.0.1
  
# ip addr show eth0
 
  
Aggiungere un indirizzo all'interfaccia eth0:
+
* Other useful commands
  
# ip addr add 192.0.2.10/24 dev eth0
+
Show devices IP addresses
 +
# ip addr
  
Cancellare un indirizzo associato all'interfaccia eth0:
+
Show information of a specific interface
 +
# ip addr show enp6s0
  
# ip addr delete 192.0.2.10/24 dev eth0
+
Add IP addresses on a device 
 +
# ip addr add 192.0.2.10/24 dev enp6s0
  
Attivare l'interfaccia eth0:
+
Delete a device IP
 +
# ip addr delete 192.0.2.10/24 dev enp6s0
  
# ip link set dev eth0 up
+
Enabling the interface enp6s0 without specifying an IP
 +
# ip link set dev enp6s0 up
  
Disattivare l'interfaccia eth0:
+
Disabling the interface enp6s0
 +
# ip link set dev enp6s0 down
  
# ip link set dev eth0 down
+
Set 192.168.0.2 as default gateway for the host
 +
# ip route add default via 192.0.2.1
  
Svuotare la cache arp per tutte le interfacce:
+
Add the gateway 192.168.0.1 route for the interfaces enp2s0 10.0.2.0
 +
# ip route add 10.0.2.1/24 via 192.168.0.1 dev enp2s0
  
# ip neigh flush all
+
Remove the gateway 192.168.0.1 route for the interfaces enp2s0 10.0.2.0
 +
# ip route del 10.0.2.0/24 via 192.168.0.1 dev enp2s0
  
Aggiungere una rotta che passa per gateway 192.0.2.1
+
Show the routing table
 +
# ip route show
  
# ip route add default via 192.0.2.1
+
https://wiki.golem.linux.it/Appunti_Arch_Linux#Networking
 
 
Aggiungere una rotta che passa per gateway 192.168.2.1 per l'interfaccia 10.0.2.0
 
 
 
# ip route add 10.0.2.1/24 via 192.168.0.1 dev enp0s3
 
 
 
Aggiungere una rotta che passa per gateway 192.168.2.1 per l'interfaccia 10.0.2.0
 
 
 
# ip route del 10.0.2.0/24 via 192.168.0.1 dev enp0s3
 
 
 
Mostrare la tabella di routing
 
 
 
# ip route show
 
  
 
= Bibliography =  
 
= Bibliography =  
 
[https://tldp.org/HOWTO/NET3-4-HOWTO-5.html Linux Networking HOWTO]
 
[https://tldp.org/HOWTO/NET3-4-HOWTO-5.html Linux Networking HOWTO]

Versione delle 09:42, 15 dic 2024

Introduction

This is the first release of the GOLEM Network Howto, this document aims to be a sort of unofficial update of the Linux Networking Howto.

General Information about Networking

Sources of non-linux-specific network information

If you are looking for general TCP/IP networking information, here you can find some resources:

IPv4 Addresses

Ipv4-1.webp

Internet Protocol v4 Addresses are composed of 4 bytes (32 bit), each byte is converted to a decimal number (0-255) and bytes are separated by a . (dot), for this reason IPv4 addresses are limits to near 4 billions (232). Usually every network interface has its own IP address in a format like this: 192.168.0.5

Subnetting

Addresses in a network have some digits in common, that part is called the network portion of the address, the remaining numbers are called the host portion.

For example:

           -----------------  ---------------
           Host Address       192.168.0.23
           Network Portion    192.168.0.
           Host portion                .23
           -----------------  ---------------
           Network Address    192.168.0.0
           Broadcast Address  192.168.0.255
           -----------------  ---------------

Subnetting is a way to subdivide an TCP/IP network. The Classless Inter-Domain Routing (CIDR) is the current method for defining subnet, the IP address is followed by a prefix number between 0 and 32 that shows how many bits represent the network.

192.168.0.23/24 => network 192.168.0.0 - 192.168.0.255
192.168.0.23/16 => network 192.168.0.0 - 192.168.255.255

This method replace the obsolete classful network addressing architecture.

The maximum number of addresses of a network may be calculated as 232 − prefix number

CIDR Classful network mask Number of Hosts Typical use
/8 255.0.0.0 16777214 = 224 - 2 Largest IANA block allocation
/9 255.128.0.0 8388608 = 223
/10 255.192.0.0 4194304 = 222
/11 255.224.0.0 2097152 = 221
/12 255.240.0.0 1048576 = 220
/13 255.248.0.0 524288 = 219
/14 255.252.0.0 262144 = 218
/15 255.254.0.0 131072 = 217
/16 255.255.0.0 65536 = 216
/17 255.255.128.0 32768 = 215 ISP / large business
/18 255.255.192.0 16384 = 214 ISP / large business
/19 255.255.224.0 8192 = 213 ISP / large business
/20 255.255.240.0 4096 = 212 Small ISP / large business
/21 255.255.248.0 2048 = 211 Small ISP / large business
/22 255.255.252.0 1024 = 210
/23 255.255.254.0 512 = 29
/24 255.255.255.0 256 = 28 Large LAN
/25 255.255.255.128 128 = 27 Large LAN
/26 255.255.255.192 64 = 26 Small LAN
/27 255.255.255.224 32 = 25 Small LAN
/28 255.255.255.240 16 = 24 Small LAN
/29 255.255.255.248 8 = 2³ The smallest multi-host network
/30 255.255.255.252 4 = 2² Point-to-point links (glue network)
/31 255.255.255.254 2 = 21 Point-to-point network (RFC 3021)
/32 255.255.255.255 1 = 20 Single host

Traffic between subnets is guaranteed by routers.

Network Configuration

Driver

Modern Linux distributions already include driver for most of LAN and WiFi devices. Otherwise try to upgrade your OS or compile and install a newer kernel.

Network tools

iproute2: IP Routing Utilities

nftables: Linux kernel packet control tool (firewall)

iputils: arping, clockdiff, ping, tracepath

Legacy tools

net-tools: configuration tools for Linux networking (arp, ifconfig, ipmaddr, iptunnel, mii-tool, nameif, netstat, plipconfig, rarp, route, slattach)

iptables: Linux kernel packet control tool (firewall)

Network Application Programs

Most common network application programs are collected in the inetutils package: dnsdomainname, ftp, ftpd, hostname, ifconfig, ping, rcp, rlogin, rlogind, rsh, rshd, talk, talkd, telnet, telnetd, whois

Setup LAN Interfaces

Predictable Network Interface Names

Starting with v197 systemd assign fixed and predictable network interface names for all local network devices instead of the traditional eth0, eth1, wlan0 which may change after a reboot post kernel update. This feature simplify the system management and fix potential security implications e.g., changing firewall rules.

These names are based on hardware firmware/topology/location information and they stay fixed even if hardware is added or removed.

Prefix	Description
en	Ethernet
ib	InfiniBand
sl	Serial line IP (slip)
wl	Wireless local area network (WLAN)
ww	Wireless wide area network (WWAN)

eth0 could be renamed enp6s0: en (ethernet) + p6 (bus 6) + s0 (slot 0)

Configuring LAN interfaces

The following commands activates the enp6s0 interface with the IP 192.168.0.2, in the subnet 192.168.0.1-255, using the router-gateway 192.168.0.1

# ip addr add 192.168.0.2/24 dev enp6s0
# ip route add default via 192.168.0.1


  • Other useful commands

Show devices IP addresses

# ip addr

Show information of a specific interface

# ip addr show enp6s0

Add IP addresses on a device

# ip addr add 192.0.2.10/24 dev enp6s0

Delete a device IP

# ip addr delete 192.0.2.10/24 dev enp6s0

Enabling the interface enp6s0 without specifying an IP

# ip link set dev enp6s0 up

Disabling the interface enp6s0

# ip link set dev enp6s0 down

Set 192.168.0.2 as default gateway for the host

# ip route add default via 192.0.2.1

Add the gateway 192.168.0.1 route for the interfaces enp2s0 10.0.2.0

# ip route add 10.0.2.1/24 via 192.168.0.1 dev enp2s0

Remove the gateway 192.168.0.1 route for the interfaces enp2s0 10.0.2.0

# ip route del 10.0.2.0/24 via 192.168.0.1 dev enp2s0 

Show the routing table

# ip route show

https://wiki.golem.linux.it/Appunti_Arch_Linux#Networking

Bibliography

Linux Networking HOWTO