Hallo,
ich bin eine neue Wohnung gezogen, in der mit Internet von meinem Vermieter zur Verfügung gestellt wird. Damit nicht jeder andere Mieter Zugriff auf meine privaten Netzwerkgeräte hat und ich sowieso noch eine Intel i340-T4 ungenutzt rumliegen habe möchte ich gerne meinen Homeserver als Router konfigurieren.
Das Beziehen von IP Adressen per DHCP funktioniert soweit auch schon aber danach fangen die Probleme an.
Direkt nachd er manuellen Konfiguration hat es bei der Namensauflösung aufgehört. Ich konnte von den Clients einen Ping an beliebige IP Adressen schicken aber nicht an Domains:
1 2 | client@client:~$ ping -c4 www.google.com ping: unknown host www.google.com |
Nach einem Neustart des Servers funktioniert nicht mal der ping an eine IP des Servers oder vom Server an den Client:
1 2 3 4 5 6 7 8 9 | client@client~$ ping -I enp0s25 -c4 192.168.188.39 PING 192.168.188.39 (192.168.188.39) from 192.168.188.89 enp0s25: 56(84) bytes of data. From 192.168.188.89 icmp_seq=1 Destination Host Unreachable From 192.168.188.89 icmp_seq=2 Destination Host Unreachable From 192.168.188.89 icmp_seq=3 Destination Host Unreachable From 192.168.188.89 icmp_seq=4 Destination Host Unreachable --- 8.8.8.8 ping statistics --- 4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3015ms pipe 3 |
Kann mir jemand sagen, was ich vergessen habe zu konfigurieren oder wo mein Fehler liegt?
Ich habe das ganze, wie folgt konfiguriert:
/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8) # The loopback interfaces auto lo iface lo inet loopback # The physical interfaces auto enp1s0f0 iface enp1s0f0 inet static address 192.168.188.36 netmask 255.255.255.0 auto enp1s0f1 iface enp1s0f1 inet static address 192.168.188.37 netmask 255.255.255.0 auto enp1s0f2 iface enp1s0f2 inet static address 192.168.188.38 netmask 255.255.255.0 auto enp1s0f3 iface enp1s0f3 inet static address 192.168.188.39 netmask 255.255.255.0 pre-up iptables-restore < /etc/iptables.rules
/etc/dnsmasq.conf
listen-address=127.0.0.1 listen-address=192.168.188.36 listen-address=192.168.188.37 listen-address=192.168.188.38 listen-address=192.168.188.39 interface=enp1s0f0 interface=enp1s0f1 interface=enp1s0f2 interface=enp1s0f3 no-dhcp-interface=enp0s31f6 dhcp-range=192.168.188.41,192.168.188.150,infinite bind-interfaces
Die Portweiterleitung habe ich wie folgt konfiguriert:
server@server:~$ sudo iptables -A FORWARD -o enp0s31f6 -i enp1s0f0 -s 192.168.188.0/24 -m conntrack --ctstate NEW -j ACCEPT server@server:~$ sudo iptables -A FORWARD -o enp0s31f6 -i enp1s0f1 -s 192.168.188.0/24 -m conntrack --ctstate NEW -j ACCEPT server@server:~$ sudo iptables -A FORWARD -o enp0s31f6 -i enp1s0f2 -s 192.168.188.0/24 -m conntrack --ctstate NEW -j ACCEPT server@server:~$ sudo iptables -A FORWARD -o enp0s31f6 -i enp1s0f3 -s 192.168.188.0/24 -m conntrack --ctstate NEW -j ACCEPT server@server:~$ sudo iptables -A FORWARD -o enp0s31f6 -s 192.168.188.0/24 -m conntrack --ctstate NEW -j ACCEPT server@server:~$ sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT server@server:~$ sudo iptables -t nat -A POSTROUTING -o enp0s31f6 -j MASQUERADE
Gespeichert habe ich die Regeln per
sudo sh -c "iptables-save > /etc/iptables.rules"
und lade diese in der /etc/network/interfaces
Ausgabe von PREROUTING und POSTROUTING via iptables -t nat -n -L -v
Chain PREROUTING (policy ACCEPT 1158 packets, 156K bytes) pkts bytes target prot opt in out source destination Chain INPUT (policy ACCEPT 70 packets, 24904 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 11 packets, 1357 bytes) pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT 9 packets, 1233 bytes) pkts bytes target prot opt in out source destination 100 6056 MASQUERADE all -- * enp0s31f6 0.0.0.0/0 0.0.0.0/0
Ausgabe von FORWARD via iptables -t filter -n -L -v
Chain INPUT (policy DROP 737 packets, 51593 bytes) pkts bytes target prot opt in out source destination 7138 2929K ufw-before-logging-input all -- * * 0.0.0.0/0 0.0.0.0/0 7138 2929K ufw-before-input all -- * * 0.0.0.0/0 0.0.0.0/0 1486 222K ufw-after-input all -- * * 0.0.0.0/0 0.0.0.0/0 785 55169 ufw-after-logging-input all -- * * 0.0.0.0/0 0.0.0.0/0 785 55169 ufw-reject-input all -- * * 0.0.0.0/0 0.0.0.0/0 785 55169 ufw-track-input all -- * * 0.0.0.0/0 0.0.0.0/0 Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 30391 40M ufw-before-logging-forward all -- * * 0.0.0.0/0 0.0.0.0/0 30391 40M ufw-before-forward all -- * * 0.0.0.0/0 0.0.0.0/0 96 5764 ufw-after-forward all -- * * 0.0.0.0/0 0.0.0.0/0 96 5764 ufw-after-logging-forward all -- * * 0.0.0.0/0 0.0.0.0/0 96 5764 ufw-reject-forward all -- * * 0.0.0.0/0 0.0.0.0/0 96 5764 ufw-track-forward all -- * * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT all -- enp1s0f0 enp0s31f6 192.168.188.0/24 0.0.0.0/0 ctstate NEW 0 0 ACCEPT all -- enp1s0f1 enp0s31f6 192.168.188.0/24 0.0.0.0/0 ctstate NEW 0 0 ACCEPT all -- enp1s0f2 enp0s31f6 192.168.188.0/24 0.0.0.0/0 ctstate NEW 96 5764 ACCEPT all -- enp1s0f3 enp0s31f6 192.168.188.0/24 0.0.0.0/0 ctstate NEW 0 0 ACCEPT all -- * enp0s31f6 192.168.188.0/24 0.0.0.0/0 ctstate NEW 0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED Chain OUTPUT (policy ACCEPT 1 packets, 84 bytes) pkts bytes target prot opt in out source destination 3108 448K ufw-before-logging-output all -- * * 0.0.0.0/0 0.0.0.0/0 3108 448K ufw-before-output all -- * * 0.0.0.0/0 0.0.0.0/0 235 24274 ufw-after-output all -- * * 0.0.0.0/0 0.0.0.0/0 235 24274 ufw-after-logging-output all -- * * 0.0.0.0/0 0.0.0.0/0 235 24274 ufw-reject-output all -- * * 0.0.0.0/0 0.0.0.0/0 235 24274 ufw-track-output all -- * * 0.0.0.0/0 0.0.0.0/0 Chain ufw-after-forward (1 references) pkts bytes target prot opt in out source destination Chain ufw-after-input (1 references) pkts bytes target prot opt in out source destination 120 10080 ufw-skip-to-policy-input udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:137 118 27760 ufw-skip-to-policy-input udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:138 0 0 ufw-skip-to-policy-input tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:139 0 0 ufw-skip-to-policy-input tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:445 0 0 ufw-skip-to-policy-input udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:67 0 0 ufw-skip-to-policy-input udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:68 463 129K ufw-skip-to-policy-input all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type BROADCAST Chain ufw-after-logging-forward (1 references) pkts bytes target prot opt in out source destination 42 2522 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 3/min burst 10 LOG flags 0 level 4 prefix "[UFW BLOCK] " Chain ufw-after-logging-input (1 references) pkts bytes target prot opt in out source destination 92 6403 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 3/min burst 10 LOG flags 0 level 4 prefix "[UFW BLOCK] " Chain ufw-after-logging-output (1 references) pkts bytes target prot opt in out source destination Chain ufw-after-output (1 references) pkts bytes target prot opt in out source destination Chain ufw-before-forward (1 references) pkts bytes target prot opt in out source destination 30293 40M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 3 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 4 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 11 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 12 2 168 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 8 96 5764 ufw-user-forward all -- * * 0.0.0.0/0 0.0.0.0/0 Chain ufw-before-input (1 references) pkts bytes target prot opt in out source destination 442 33806 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 3152 1973K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED 0 0 ufw-logging-deny all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 3 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 4 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 11 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 12 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 8 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp spt:67 dpt:68 3544 922K ufw-not-local all -- * * 0.0.0.0/0 0.0.0.0/0 231 29840 ACCEPT udp -- * * 0.0.0.0/0 224.0.0.251 udp dpt:5353 1821 669K ACCEPT udp -- * * 0.0.0.0/0 239.255.255.250 udp dpt:1900 1492 224K ufw-user-input all -- * * 0.0.0.0/0 0.0.0.0/0 Chain ufw-before-logging-forward (1 references) pkts bytes target prot opt in out source destination Chain ufw-before-logging-input (1 references) pkts bytes target prot opt in out source destination Chain ufw-before-logging-output (1 references) pkts bytes target prot opt in out source destination Chain ufw-before-output (1 references) pkts bytes target prot opt in out source destination 442 33806 ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0 2431 390K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED 235 24274 ufw-user-output all -- * * 0.0.0.0/0 0.0.0.0/0 Chain ufw-logging-allow (0 references) pkts bytes target prot opt in out source destination 0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 3/min burst 10 LOG flags 0 level 4 prefix "[UFW ALLOW] " Chain ufw-logging-deny (2 references) pkts bytes target prot opt in out source destination 0 0 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID limit: avg 3/min burst 10 0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 3/min burst 10 LOG flags 0 level 4 prefix "[UFW BLOCK] " Chain ufw-not-local (1 references) pkts bytes target prot opt in out source destination 738 53501 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL 2100 700K RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type MULTICAST 706 168K RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type BROADCAST 0 0 ufw-logging-deny all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 3/min burst 10 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 Chain ufw-reject-forward (1 references) pkts bytes target prot opt in out source destination Chain ufw-reject-input (1 references) pkts bytes target prot opt in out source destination Chain ufw-reject-output (1 references) pkts bytes target prot opt in out source destination Chain ufw-skip-to-policy-forward (0 references) pkts bytes target prot opt in out source destination 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 Chain ufw-skip-to-policy-input (7 references) pkts bytes target prot opt in out source destination 701 167K DROP all -- * * 0.0.0.0/0 0.0.0.0/0 Chain ufw-skip-to-policy-output (0 references) pkts bytes target prot opt in out source destination 0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 Chain ufw-track-forward (1 references) pkts bytes target prot opt in out source destination Chain ufw-track-input (1 references) pkts bytes target prot opt in out source destination Chain ufw-track-output (1 references) pkts bytes target prot opt in out source destination 6 360 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 ctstate NEW 212 23014 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 ctstate NEW Chain ufw-user-forward (1 references) pkts bytes target prot opt in out source destination Chain ufw-user-input (1 references) pkts bytes target prot opt in out source destination 1 60 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:22 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:67 5 1655 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:67 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:9982 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:9982 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:9981 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:9981 Chain ufw-user-limit (0 references) pkts bytes target prot opt in out source destination 0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 3/min burst 5 LOG flags 0 level 4 prefix "[UFW LIMIT BLOCK] " 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable Chain ufw-user-limit-accept (0 references) pkts bytes target prot opt in out source destination 0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 Chain ufw-user-logging-forward (0 references) pkts bytes target prot opt in out source destination Chain ufw-user-logging-input (0 references) pkts bytes target prot opt in out source destination Chain ufw-user-logging-output (0 references) pkts bytes target prot opt in out source destination Chain ufw-user-output (1 references) pkts bytes target prot opt in out source destination
/etc/sysctl.conf
# # /etc/sysctl.conf - Configuration file for setting system variables # See /etc/sysctl.d/ for additional system variables. # See sysctl.conf (5) for information. # #kernel.domainname = example.com # Uncomment the following to stop low-level messages on console #kernel.printk = 3 4 1 3 ##############################################################3 # Functions previously found in netbase # # Uncomment the next two lines to enable Spoof protection (reverse-path filter) # Turn on Source Address Verification in all interfaces to # prevent some spoofing attacks #net.ipv4.conf.default.rp_filter=1 #net.ipv4.conf.all.rp_filter=1 # Uncomment the next line to enable TCP/IP SYN cookies # See http://lwn.net/Articles/277146/ # Note: This may impact IPv6 TCP sessions too #net.ipv4.tcp_syncookies=1 # Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.ip_forward=1 # Uncomment the next line to enable packet forwarding for IPv6 # Enabling this option disables Stateless Address Autoconfiguration # based on Router Advertisements for this host #net.ipv6.conf.all.forwarding=1 ################################################################### # Additional settings - these settings can improve the network # security of the host and prevent against some network attacks # including spoofing attacks and man in the middle attacks through # redirection. Some network environments, however, require that these # settings are disabled so review and enable them as needed. # # Do not accept ICMP redirects (prevent MITM attacks) #net.ipv4.conf.all.accept_redirects = 0 #net.ipv6.conf.all.accept_redirects = 0 # _or_ # Accept ICMP redirects only for gateways listed in our default # gateway list (enabled by default) # net.ipv4.conf.all.secure_redirects = 1 # # Do not send ICMP redirects (we are not a router) #net.ipv4.conf.all.send_redirects = 0 # # Do not accept IP source route packets (we are not a router) #net.ipv4.conf.all.accept_source_route = 0 #net.ipv6.conf.all.accept_source_route = 0 # # Log Martian Packets #net.ipv4.conf.all.log_martians = 1 #
Vielen Dank für eure Hilfe.
Sven