Table of Contents

Netzwerkkonfiguration

Nützliche Befehle

sysctl -w net.ipv4.ip_default_ttl=128   # TTL temp. setzen 128 = Windows default
ping 192.168.1.1                        # Dauerping
ping -c 4 192.168.1.1                   # 4 Pings
netstat -npl                            # offene Ports auflisten
netstat -tulpn                          # offene Ports auflisten
ss -tulpn                               # offene Ports auflisten
lsof -i | grep -e LISTEN                # offene Ports auflisten
cat < /dev/tcp/127.0.0.1/22             # Teste Ports mit cat

Debian

/etc/network/interfaces.d
/etc/network/interfaces

sudo systemctl restart networking.service

Static

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens192
iface ens192 inet static
  address 192.168.2.236
  netmask 255.255.255.0
  gateway 192.168.2.254
  dns-domain sweet.home
  dns-nameservers 192.168.2.254 1.1.1.1 8.8.8.8
sudo ip addr add 123.222.111.123 dev ens192             #temporär 2. IP hinzufügen (bis reboot)

DHCP

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens192
iface ens192 inet dhcp

SLES

Wichtige Dateien

Pfad Verantwortlich für
/etc/udev/rules.d/70-persistent-net.rules
/etc/sysconfig/network/ifcfg-eth0 Beinhaltet die Netzwerkkonfiguration für das Interface “eth0”
/etc/sysconfig/network/routes
/etc/resolve.conf
/etc/HOSTNAME
/etc/hosts

Route

/etc/sysconfig/network/routes

Beispiel

default 192.168.63.1 - -

Priorität der Adapter

/etc/udev/rules.d/70-persistent-net.rules

Allgemein

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<MAC-Adresse>", ATTR{type}=="1", KERNEL=="eth*", NAME="<ADAPTERNAME>"

Beispiel

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:85:54:00", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Netzwerkadapter Einstellungen

/etc/sysconfig/network/ifcfg-eth0

Beispiel DHCP

BOOTPROTO='dhcp' 			#or static
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR=''				#assigned if static e.g. 10.6.7.203
MTU=''
NAME='AMD PCnet - Fast 79C971'
NETMASK=''
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='auto'
UNIQUE='rBUF.weGuQ9ywYPF'
USERCONTROL='no'
_nm_name='bus-pci-0000:02:01.0'

Beispiel Statische IP

BOOTPROTO='static'
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR='10.6.7.203'
MTU=''
NAME='AMD PCnet - Fast 79C971'
NETMASK='255.255.255.0'
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='auto'
UNIQUE='rBUF.weGuQ9ywYPF'
USERCONTROL='no'
_nm_name='bus-pci-0000:02:01.0'

Hostname für FQDN

/etc/HOSTNAME

Allgemein

<Computername>.<Domain>

DNS-Einstellungen

/etc/resolve.conf

Allgemein

domain <Domain>
nameserver <IP_des_Servers>
nameserver <Ggf_IP_des_2._Servers>

Beispiel

domain site
nameserver 10.0.0.1
nameserver 10.0.0.2

hosts

/etc/hosts → vergleichbar wie in Windows

Allgemein

127.0.0.1   localhost
<lokale IP> <Computername>.<Domain> <Computername>

Beispiel

127.0.0.1       localhost
10.0.0.202      srstef.site srstef

iptables

http://jensd.be/343/linux/forward-a-tcp-port-to-another-ip-or-port-using-nat-with-iptables