Alpine Router
Alpine linux NAT router mit iptables und dnsmasq für privates Netzwerk mit DNS und DHCP.
Als Basis werden eth0 als WAN und eth1 als LAN1 eingerichtet.
für
--------------------Beispiel /etc/network/interfaces---------------
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.1.2
netmask 255.255.255.0
( auto eth2
iface eth2 inet static
address 192.168.2.2
netmask 255.255.255.0
.
.
. )
#!/bin/sh # script iptables.sh apk add iptables rc-update add iptables echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -A FORWARD -i eth1 -j ACCEPT /etc/init.d/iptables save #/sbin/reboot
#!/bin/sh # script dnsmasq.sh apk add dnsmasq rc-update add dnsmasq # interface - interface to listen for DHCP and DNS requests # domain - domain for the private network # dhcp_range - lower bound, upper bound, lease timeout interface=eth1 domain=example.com dhcp_range="192.168.1.100,192.168.1.254,12h" sed -i \ "s/^#\?\(interface=\).*/\1$interface/; \ s/^#\(listen-address\)=.*/\1=127.0.0.1/; \ s/^#\(expand-hosts\)/\1/; \ s/^#\?\(domain=\)[^,]*$/\1$domain/; \ s/^#\?\(dhcp-range=\)\d\{1,3\}.\d\{1,3\}.\d\{1,3\}.\d\{1,3\},\d\{1,3\}.\d\{1,3\}.\d\{1,3\}.\d\{1,3\},[^,]*$/\1$dhcp_range/" \ /etc/dnsmasq.conf #/sbin/reboot
static ip, nameserver resolf.conf
add nameserver 8.8.8.8
apk add util-linux
zur Funktionserweiterung von dmesg, sonst kein -T etc.