• Aucun résultat trouvé

Ethernet Interfaces

Ethernet interfaces are identified by the system using predictable network interface names. These names can appear as eno1or enp0s25. However, in some cases an interface may still use the kerneleth#style of naming.

Identify Ethernet Interfaces

To quickly identify all available Ethernet interfaces, you can use the ip command as shown below.

i p a

1 : l o : <LOOPBACK, UP,LOWER_UP> mtu 65536 q d i s c noqueue s t a t e UNKNOWN group d e f a u l t q l e n 1000

l i n k / l o o p b a c k 0 0 : 0 0 : 0 0 : 0 0 : 0 0 : 0 0 brd 0 0 : 0 0 : 0 0 : 0 0 : 0 0 : 0 0 i n e t 1 2 7 . 0 . 0 . 1 / 8 s c o p e h o s t l o

v a l i d _ l f t f o r e v e r p r e f e r r e d _ l f t f o r e v e r i n e t 6 : : 1 / 1 2 8 s c o p e h o s t

v a l i d _ l f t f o r e v e r p r e f e r r e d _ l f t f o r e v e r

2 : enp0s25 : <BROADCAST,MULTICAST, UP,LOWER_UP> mtu 1500 q d i s c noqueue s t a t e UP group d e f a u l t q l e n 1000

l i n k / e t h e r 0 0 : 1 6 : 3 e : e2 : 5 2 : 4 2 brd f f : f f : f f : f f : f f : f f l i n k−n e t n s i d 0 i n e t 1 0 . 1 0 2 . 6 6 . 2 0 0 / 2 4 brd 1 0 . 1 0 2 . 6 6 . 2 5 5 s c o p e g l o b a l dynamic e t h 0

v a l i d _ l f t 3257 s e c p r e f e r r e d _ l f t 3257 s e c i n e t 6 f e 8 0 : : 2 1 6 : 3 e f f : f e e 2 : 5 2 4 2 / 6 4 s c o p e l i n k

v a l i d _ l f t f o r e v e r p r e f e r r e d _ l f t f o r e v e r

Another application that can help identify all network interfaces available to your system is the lshw command.

This command provides greater details around the hardware capabilities of specific adapters. In the example below, lshw shows a single Ethernet interface with the logical name of eth0 along with bus information, driver details and all supported capabilities.

sudo lshw −c l a s s network

*−network

d e s c r i p t i o n : E t h e r n e t i n t e r f a c e

pr o d u c t : MT26448 [ ConnectX EN 10GigE , PCIe 2 . 0 5GT/ s ] vendor : Mellanox T e c h n o l o g i e s

p h y s i c a l i d : 0

bus i n f o : pci@0004 : 0 1 : 0 0 . 0 l o g i c a l name : e t h 4

v e r s i o n : b0

s e r i a l : e4 : 1 d : 2 d : 6 7 : 8 3 : 5 6

s l o t : U78CB . 0 0 1 . WZS09KB−P1−C6−T1 s i z e : 10 Gbit / s

c a p a c i t y : 10 Gbit / s width : 64 b i t s c l o c k : 33MHz

c a p a b i l i t i e s : pm vpd msix p c i e x p r e s s bus_master c a p _ l i s t e t h e r n e t p h y s i c a l f i b r e 10000 bt−f d

c o n f i g u r a t i o n : a u t o n e g o t i a t i o n=o f f b r o a d c a s t=y e s d r i v e r=mlx4_en d r i v e r v e r s i o n =4.0−0 duplex= f u l l f i r m w a r e = 2 . 9 . 1 3 2 6 i p = 1 9 2 . 1 6 8 . 1 . 1 l a t e n c y =0 l i n k=y e s m u l t i c a s t=y e s p o r t=f i b r e s p e e d =10Gbit / s

r e s o u r c e s : iomemory :24000−23 f f f i r q : 4 8 1 memory : 3 f e 2 0 0 0 0 0 0 0 0−3 f e 2 0 0 0 f f f f f memory:240000000000−240007 f f f f f f

Ethernet Interface Logical Names

Interface logical names can also be configured via a netplan configuration. If you would like control which interface receives a particular logical name use thematchandset-name keys. The match key is used to find an adapter based on some criteria like MAC address, driver, etc. Then the set-name key can be used to change the device to the desired logial name.

network : v e r s i o n : 2

r e n d e r e r : networkd e t h e r n e t s :

eth_lan0 : dhcp4 : t r u e match :

macaddress : 0 0 : 1 1 : 2 2 : 3 3 : 4 4 : 5 5 s e t−name : eth_lan0

Ethernet Interface Settings

ethtool is a program that displays and changes Ethernet card settings such as auto-negotiation, port speed, duplex mode, and Wake-on-LAN. The following is an example of how to view supported features and con-figured settings of an Ethernet interface.

sudo e t h t o o l e t h 4 S e t t i n g s f o r e t h 4 :

Supported p o r t s : [ FIBRE ]

Supported l i n k modes : 10000 baseT / F u l l Supported pause frame u s e : No

Su pports auto−n e g o t i a t i o n : No Supported FEC modes : Not r e p o r t e d

A d v e r t i s e d l i n k modes : 10000 baseT / F u l l A d v e r t i s e d pause frame u s e : No

A d v e r t i s e d auto−n e g o t i a t i o n : No A d v e r t i s e d FEC modes : Not r e p o r t e d Speed : 10000Mb/ s

Duplex : F u l l Port : FIBRE PHYAD: 0

T r a n s c e i v e r : i n t e r n a l Auto−n e g o t i a t i o n : o f f Su pports Wake−on : d Wake−on : d

Current message l e v e l : 0 x00000014 ( 2 0 ) l i n k ifdown

Link d e t e c t e d : y e s

IP Addressing

The following section describes the process of configuring your systems IP address and default gateway needed for communicating on a local area network and the Internet.

Temporary IP Address Assignment

For temporary network configurations, you can use the ip command which is also found on most other GNU/Linux operating systems. The ip command allows you to configure settings which take effect immedi-ately, however they are not persistent and will be lost after a reboot.

To temporarily configure an IP address, you can use the ip command in the following manner. Modify the IP address and subnet mask to match your network requirements.

sudo i p addr add 1 0 . 1 0 2 . 6 6 . 2 0 0 / 2 4 dev enp0s25 The ip can then be used to set the link up or down.

i p l i n k s e t dev enp0s25 up i p l i n k s e t dev enp0s25 down

To verify the IP address configuration of enp0s25, you can use the ip command in the following manner.

i p a d d r e s s show dev enp0s25

1 0 : enp0s25 : <BROADCAST,MULTICAST, UP,LOWER_UP> mtu 1500 q d i s c noqueue s t a t e UP group d e f a u l t q l e n 1000

l i n k / e t h e r 0 0 : 1 6 : 3 e : e2 : 5 2 : 4 2 brd f f : f f : f f : f f : f f : f f l i n k−n e t n s i d 0 i n e t 1 0 . 1 0 2 . 6 6 . 2 0 0 / 2 4 brd 1 0 . 1 0 2 . 6 6 . 2 5 5 s c o p e g l o b a l dynamic e t h 0

v a l i d _ l f t 2857 s e c p r e f e r r e d _ l f t 2857 s e c i n e t 6 f e 8 0 : : 2 1 6 : 3 e f f : f e e 2 : 5 2 4 2 / 6 4 s c o p e l i n k

v a l i d _ l f t f o r e v e r p r e f e r r e d _ l f t f o r e v e r 6

To configure a default gateway, you can use the ip command in the following manner. Modify the default gateway address to match your network requirements.

sudo i p r o u t e add d e f a u l t v i a 1 0 . 1 0 2 . 6 6 . 1

To verify your default gateway configuration, you can use the ip command in the following manner.

i p r o u t e show

d e f a u l t v i a 1 0 . 1 0 2 . 6 6 . 1 dev e t h 0 p r o t o dhcp s r c 1 0 . 1 0 2 . 6 6 . 2 0 0 m e t r i c 100 1 0 . 1 0 2 . 6 6 . 0 / 2 4 dev e t h 0 p r o t o k e r n e l s c o p e l i n k s r c 1 0 . 1 0 2 . 6 6 . 2 0 0

1 0 . 1 0 2 . 6 6 . 1 dev e t h 0 p r o t o dhcp s c o p e l i n k s r c 1 0 . 1 0 2 . 6 6 . 2 0 0 m e t r i c 100

If you require DNS for your temporary network configuration, you can add DNS server IP addresses in the file /etc/resolv .conf. In general, editing /etc/resolv .conf directly is not recommanded, but this is a temporary and non-persistent configuration. The example below shows how to enter two DNS servers to /etc/resolv . conf, which should be changed to servers appropriate for your network. A more lengthy description of the proper persistent way to do DNS client configuration is in a following section.

nameserver 8 . 8 . 8 . 8 nameserver 8 . 8 . 4 . 4

If you no longer need this configuration and wish to purge all IP configuration from an interface, you can use the ip command with the flush option as shown below.

i p addr f l u s h e t h 0 Note

Flushing the IP configuration using the ip command does not clear the contents of /etc/resolv .conf. You must remove or modify those entries manually, or re-boot which should also cause /etc/resolv .conf, which is a symlink to /run/systemd/resolve/stub−resolv.conf, to be re-written.

Dynamic IP Address Assignment (DHCP Client)

To configure your server to use DHCP for dynamic address assignment, create a netplan configuration in the file /etc/netplan/99_config.yaml. The example below assumes you are configuring your first Ethernet interface identified asenp3s0.

network : v e r s i o n : 2

r e n d e r e r : networkd e t h e r n e t s :

enp3s0 :

dhcp4 : t r u e

The configuration can then be applied using the netplan command.

sudo n e t p l a n apply

Static IP Address Assignment

To configure your system to use static address assignment, create a netplan configuration in the file /etc /netplan/99_config.yaml. The example below assumes you are configuring your first Ethernet interface identified aseth0. Change theaddresses,gateway4, andnameserversvalues to meet the requirements of your network.

network : v e r s i o n : 2

r e n d e r e r : networkd e t h e r n e t s :

e t h 0 :

a d d r e s s e s :

− 1 0 . 1 0 . 1 0 . 2 / 2 4 gateway4 : 1 0 . 1 0 . 1 0 . 1 n a m e s e r v e r s :

s e a r c h : [ mydomain , otherdomain ] a d d r e s s e s : [ 1 0 . 1 0 . 1 0 . 1 , 1 . 1 . 1 . 1 ]

The configuration can then be applied using the netplan command.

sudo n e t p l a n apply

Loopback Interface

The loopback interface is identified by the system as loand has a default IP address of 127.0.0.1. It can be viewed using the ip command.

i p a d d r e s s show l o

1 : l o : <LOOPBACK, UP,LOWER_UP> mtu 65536 q d i s c noqueue s t a t e UNKNOWN group d e f a u l t q l e n 1000

l i n k / l o o p b a c k 0 0 : 0 0 : 0 0 : 0 0 : 0 0 : 0 0 brd 0 0 : 0 0 : 0 0 : 0 0 : 0 0 : 0 0 i n e t 1 2 7 . 0 . 0 . 1 / 8 s c o p e h o s t l o

v a l i d _ l f t f o r e v e r p r e f e r r e d _ l f t f o r e v e r i n e t 6 : : 1 / 1 2 8 s c o p e h o s t

v a l i d _ l f t f o r e v e r p r e f e r r e d _ l f t f o r e v e r