/etc/network/interfaces: Unterschied zwischen den Versionen

Aus Foxwiki
K Textersetzung - „== Syntax ==“ durch „== Aufruf ==“
 
(29 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
'''topic''' kurze Beschreibung
'''topic''' - Beschreibung
== Beschreibung ==
== Beschreibung ==
The file''' /etc/network/interfaces '''available in Debian and its derived distributions allows to define static and dynamic IP addresses for the interfaces, setup routing information and default gateways, masquerading network bonding and more.
The file''' /etc/network/interfaces '''available in Debian and its derived distributions allows to define static and dynamic IP addresses for the interfaces, setup routing information and default gateways, masquerading network bonding and more.
Zeile 5: Zeile 5:
The default '''''interfaces''''' file looks like the following:
The default '''''interfaces''''' file looks like the following:


[[Image:Bild12.png|top]]Where '''auto '''starts the interface at boot and '''iface''' calls the network interface (in this case lo, loopback). All lines beginning with  “'''auto'''” specify the interfaces which will be enabled when running “'''''ifup -a'''''”, a command executed at boot.
Image:Bild12.png|top
 
Where '''auto '''starts the interface at boot and '''iface''' calls the network interface (in this case lo, loopback). All lines beginning with “'''auto'''” specify the interfaces which will be enabled when running “'''''ifup -a'''''”, a command executed at boot.


Lines beginning with “iface” have the following syntax
Lines beginning with “iface” have the following syntax
  iface&nbsp; <interface>&nbsp; <address_family>&nbsp; <method>
  iface&nbsp;<interface>&nbsp;<address_family>&nbsp;<method>


For example
For example
  iface enp2s0 inet dhcp
  iface enp2s0 inet dhcp


The following example shows how to setup a network card using DHCP:
== Installation ==
== Anwendungen ==
== Anwendungen ==
=== Fehlerbehebung ===
=== DHCP ===
== Syntax ==
; The following example shows how to setup a network card using DHCP
=== Optionen ===
=== Parameter ===
=== Umgebungsvariablen ===
=== Exit-Status ===
== Konfiguration ==
=== Dateien ===
== Sicherheit ==
== Dokumentation ==
=== RFC ===
=== Man-Pages ===
=== Info-Pages ===
== Siehe auch ==
== Links ==
=== Projekt-Homepage ===
=== Weblinks ===
=== Einzelnachweise ===
<references />
== Testfragen ==
<div class="toccolours mw-collapsible mw-collapsed">
''Testfrage 1''
<div class="mw-collapsible-content">'''Antwort1'''</div>
</div>
<div class="toccolours mw-collapsible mw-collapsed">
''Testfrage 2''
<div class="mw-collapsible-content">'''Antwort2'''</div>
</div>
<div class="toccolours mw-collapsible mw-collapsed">
''Testfrage 3''
<div class="mw-collapsible-content">'''Antwort3'''</div>
</div>
<div class="toccolours mw-collapsible mw-collapsed">
''Testfrage 4''
<div class="mw-collapsible-content">'''Antwort4'''</div>
</div>
<div class="toccolours mw-collapsible mw-collapsed">
''Testfrage 5''
<div class="mw-collapsible-content">'''Antwort5'''</div>
</div>
 
[[Kategorie:Entwurf]]
 
= TMP =
== DHCP ==
To add a new interface using DHCP, add the following lines:
To add a new interface using DHCP, add the following lines:
  auto <Interface>allow-hotplug <Interface>iface <Interface> inet dhcp
  auto <Interface>
allow-hotplug <Interface>
iface <Interface> inet dhcp


[[Image:Bild13.png|top]]
Image:Bild13.png|top]]


Where '''allow-hotplug''' will start the interface upon event detection.
Where '''allow-hotplug''' will start the interface upon event detection.
Zeile 73: Zeile 31:
* Where '''<interface>''' you should set your device name, '''eth0''', '''enp2s0''', '''wlp3s0''', etc.
* Where '''<interface>''' you should set your device name, '''eth0''', '''enp2s0''', '''wlp3s0''', etc.


== Static address ==
=== Static address ===
If instead of configuring the interface with DHCP you want to set a static IP address and gateway replace the previous instructions with the following (replace '''192.168.0.8/24''' and '''192.168.0.1 '''with your correct IP addresses):
If instead of configuring the interface with DHCP you want to set a static IP address and gateway replace the previous instructions with the following (replace '''192.168.0.8/24''' and '''192.168.0.1 '''with your correct IP addresses):
  auto <Interface>iface  
  auto <Interface>iface
  <Interface> inet staticaddress 192.168.0.1
  <Interface> inet staticaddress 192.168.0.1
  netmask 255.255.255.0
  netmask 255.255.255.0
Zeile 81: Zeile 39:
  dns-nameservers 8.8.8.8
  dns-nameservers 8.8.8.8


[[Image:Bild14.png|top]]
Image:Bild14.png|top]]


Defining gateway and broadcast is optional.
Defining gateway and broadcast is optional.
* The following example shows a different configuration which runs after the network interface is enabled (up) or disabled (down).  
* The following example shows a different configuration which runs after the network interface is enabled (up) or disabled (down).
* The “'''''up'''''” lines are executed when the device is enabled while the “'''''down”''''' lines when it is disabled:
* The “'''''up'''''” lines are executed when the device is enabled while the “'''''down”''''' lines when it is disabled:
  auto eth0
  auto eth0
Zeile 95: Zeile 53:
  down route del -net 192.168.0.128 netmask 255.255.255.128 gw 192.168.0.1
  down route del -net 192.168.0.128 netmask 255.255.255.128 gw 192.168.0.1


[[Image:Bild15.png|top]]
Image:Bild15.png|top]]


== Network card with 2 interfaces ==
=== Network card with 2 interfaces ===
; Static configuration for a network card with two interfaces
; Static configuration for a network card with two interfaces
  auto eth0 eth0:1
  auto eth0 eth0:1
 
  iface eth0  
  iface eth0
  inet staticaddress 192.168.0.5
  inet staticaddress 192.168.0.5
  network 192.168.0.0
  network 192.168.0.0
Zeile 107: Zeile 65:
  broadcast 192.168.0.255
  broadcast 192.168.0.255
  gateway 192.168.0.1
  gateway 192.168.0.1
 
  iface eth0:1
  iface eth0:1
  inet staticaddress 192.168.0.10
  inet staticaddress 192.168.0.10
Zeile 113: Zeile 71:
  netmask 255.255.255.0
  netmask 255.255.255.0


== Bonding ==
=== Bonding ===
siehe [[Linux:Bonding]]
siehe [[Bonding]]


== Logging ==
=== Logging ===
: Enable logging for the file /etc/network/interfaces
: Enable logging for the file /etc/network/interfaces
* There are 3 options related to the logging:
* There are 3 options related to the logging:
Zeile 129: Zeile 87:
*  save logs within /var/log/syslog
*  save logs within /var/log/syslog


[[Image:Bild20.png|top]]
Image:Bild20.png|top]]


; Pre-up commands for /etc/network/interfaces
=== Pre-up commands for /etc/network/interfaces ===
* Pre-up commands are executed before enabling the network device
* Pre-up commands are executed before enabling the network device
* If the pre-up command fails the network card activation wont take place
* If the pre-up command fails the network card activation wont take place
Zeile 151: Zeile 109:
# Quelle: https://linuxhint.com/debian_etc_network_interfaces/
# Quelle: https://linuxhint.com/debian_etc_network_interfaces/


== Persistente Routen ==
=== Persistente Routen ===
Dauerhafte (persistente) statische Routen werden in /etc/network/interfaces eingetragen
Dauerhafte (persistente) statische Routen werden in /etc/network/interfaces eingetragen


Zeile 159: Zeile 117:
  auto lo
  auto lo
  iface lo inet loopback
  iface lo inet loopback
 
  #--------------------------------------------#
  #--------------------------------------------#
  # Setup eth0 - connected to private LAN/VLAN #
  # Setup eth0 - connected to private LAN/VLAN #
  #--------------------------------------------#  
  #--------------------------------------------#
  auto eth0
  auto eth0
  allow-hotplug eth0
  allow-hotplug eth0
Zeile 184: Zeile 142:
  # service networking restart
  # service networking restart


= Links =
== Aufruf ==
== Intern ==
=== Optionen ===
== Weblinks ==
=== Parameter ===
=== Umgebung ===
=== Rückgabewert ===
== Konfiguration ==
=== Dateien ===
== Sicherheit ==
== Dokumentation ==
=== RFC ===
=== Man-Page ===
=== Info-Pages ===
== Siehe auch ==
== Links ==
=== Projekt ===
=== Weblinks ===
# https://www.cyberciti.biz/tips/configuring-static-routes-in-debian-or-red-hat-linux-systems.html
# https://www.cyberciti.biz/tips/configuring-static-routes-in-debian-or-red-hat-linux-systems.html


 
[[Kategorie:Linux/Netzwerk]]
[[Kategorie:Linux:Netzwerk]]
[[Kategorie:Linux/Konfiguration/Datei]]

Aktuelle Version vom 12. November 2024, 18:40 Uhr

topic - Beschreibung

Beschreibung

The file /etc/network/interfaces available in Debian and its derived distributions allows to define static and dynamic IP addresses for the interfaces, setup routing information and default gateways, masquerading network bonding and more.

The default interfaces file looks like the following:

Image:Bild12.png|top

Where auto starts the interface at boot and iface calls the network interface (in this case lo, loopback). All lines beginning with “auto” specify the interfaces which will be enabled when running “ifup -a”, a command executed at boot.

Lines beginning with “iface” have the following syntax

iface <interface> <address_family> <method>

For example

iface enp2s0 inet dhcp

Anwendungen

DHCP

The following example shows how to setup a network card using DHCP

To add a new interface using DHCP, add the following lines:

auto <Interface>
allow-hotplug <Interface>
iface <Interface> inet dhcp
Image:Bild13.png|top]]

Where allow-hotplug will start the interface upon event detection.

Note
  • for IPv6 add “inet6”: iface <interface> inet6 dhcp
  • Where <interface> you should set your device name, eth0, enp2s0, wlp3s0, etc.

Static address

If instead of configuring the interface with DHCP you want to set a static IP address and gateway replace the previous instructions with the following (replace 192.168.0.8/24 and 192.168.0.1 with your correct IP addresses):

auto <Interface>iface
<Interface> inet staticaddress 192.168.0.1
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8
Image:Bild14.png|top]]

Defining gateway and broadcast is optional.

  • The following example shows a different configuration which runs after the network interface is enabled (up) or disabled (down).
  • The “up” lines are executed when the device is enabled while the “down” lines when it is disabled:
auto eth0
iface eth0 inet staticaddress 192.168.0.5
network 192.168.0.0
netmask 255.255.255.128
broadcast 192.168.0.0
up route add -net 192.168.0.128 netmask 255.255.255.0 gw 192.168.0.1up route add default gw 192.168.0.200
down route del default gw 192.168.0.200
down route del -net 192.168.0.128 netmask 255.255.255.128 gw 192.168.0.1
Image:Bild15.png|top]]

Network card with 2 interfaces

Static configuration for a network card with two interfaces
auto eth0 eth0:1
iface eth0
inet staticaddress 192.168.0.5
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
iface eth0:1
inet staticaddress 192.168.0.10
network 192.168.0.0
netmask 255.255.255.0

Bonding

siehe Bonding

Logging

Enable logging for the file /etc/network/interfaces
  • There are 3 options related to the logging:
VERBOSE
  • instructs log files to have detailed information
DEBUG
  • enable debugging when logging
SYSLOG
  • save logs within /var/log/syslog
Image:Bild20.png|top]]

Pre-up commands for /etc/network/interfaces

  • Pre-up commands are executed before enabling the network device
  • If the pre-up command fails the network card activation wont take place
Post-up instructions for /etc/network/interfaces
  • Post-up instructions are executed after the network interface is enabled
Pre-down instructions for /etc/network/interfaces
  • Pre-down instructions are executed before disabling the network device

'* Post-down instructions for /etc/network/interfaces: Post-down instructions are executed after the network interface is disabled

Pre-up, pre-down, post-up and post-down flags are conditional, if they ail the network device won’t get enabled or won’t be properly marked as disabled.

For example, the instruction:

pre-up /usr/local/sbin/iptables

Will run the firewall before the network interface gets enabled, if iptables fails to start the network interface wont turn on.

  1. Quelle: https://linuxhint.com/debian_etc_network_interfaces/

Persistente Routen

Dauerhafte (persistente) statische Routen werden in /etc/network/interfaces eingetragen

#--------------------------------------------#
# Setup the loopback network interface (lo0) #
#--------------------------------------------#
auto lo
iface lo inet loopback
#--------------------------------------------#
# Setup eth0 - connected to private LAN/VLAN #
#--------------------------------------------#
auto eth0
allow-hotplug eth0
iface eth0 inet static
       address 10.70.201.5
       netmask 255.255.255.192
       ### add persistent route command ###
       post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.70.201.6
#----------------------------------------#
# Setup eth1 - connected to the Internet #
#----------------------------------------#
auto eth1
allow-hotplug eth1
iface eth1 inet static
       address 205.153.203.98
       netmask 255.255.255.248
       ### default gateway ###
       gateway 205.153.203.97
# service networking restart

Aufruf

Optionen

Parameter

Umgebung

Rückgabewert

Konfiguration

Dateien

Sicherheit

Dokumentation

RFC

Man-Page

Info-Pages

Siehe auch

Links

Projekt

Weblinks

  1. https://www.cyberciti.biz/tips/configuring-static-routes-in-debian-or-red-hat-linux-systems.html