Estou tentando aprender sobre rede, especificamente, o que estou tentando atualmente é criar uma rede privada que seja executada atrás de um NAT que se conecte ao meu roteador principal.
A maneira como pensei nisso é a seguinte:
+---------------------------------------------------+
|10.0.0.0/24 |
| +-------+ |
+------+---------------------------+ |Switch | +-----+ |
|Raspberry Pi | | +---+ | |
| | | | +-----+ |
| eth1+---+ | |
+-----------------+ | 10.0.0.1| | | |
|Router | | | | | +-----+ |
|192.168.100.1 +---+eth0 dnsmasq settings| | +---+ | |
+---+dhcp: | |192.168.100.5 range: 10.0.0.2/24| | | +-----+ |
|192.168.100.2/24 | | gateway: 10.0.0.1| +-------+ |
| | | | |
+-----+------+----+ +------+---------------------------+ |
| | | |
| | +---------------------------------------------------+
| |
| +------------------------------------+ Other devices
|
| +---------------+
| |pi-hole |
+-------+192.168.100.3 |
| |
+---------------+
Agora acho que configurei o pi da framboesa corretamente. As configurações são as seguintes:
/etc/dnsmasq.conf
domain=local.pi
local=/local.pi/
no-hosts
addn-hosts=/etc/hosts.d
localise-queries
no-poll
no-resolv
cache-size=10000
log-async
log-queries=extra
log-facility=/var/log/dnsmasq/dnsmasq.log
local-ttl=2
server=192.168.100.3
server=9.9.9.9
domain-needed
bogus-priv
interface=eth1
dhcp-authoritative
dhcp-range=10.0.0.2,10.0.0.254,1h
dhcp-option=option:router,10.0.0.1
dhcp-leasefile=/etc/dhcp.leases
No entanto, o dnsmasq não parece distribuir nenhum endereço IP, como é evidente pelos logs:
Sep 30 22:37:25 dnsmasq[3296]: started, version 2.76 cachesize 10000
Sep 30 22:37:25 dnsmasq[3296]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify
Sep 30 22:37:25 dnsmasq-dhcp[3296]: DHCP, IP range 10.0.0.2 -- 10.0.0.254, lease time 1h
Sep 30 22:37:25 dnsmasq[3296]: using nameserver 9.9.9.9#53
Sep 30 22:37:25 dnsmasq[3296]: using nameserver 192.168.100.3#53
Sep 30 22:37:25 dnsmasq[3296]: using local addresses only for domain local.pi
Sep 30 22:37:33 dnsmasq-dhcp[3296]: no address range available for DHCP request via eth1
Essa última mensagem é repetida continuamente quando os clientes solicitam um IP. O seguinte é a saída do tcpdump:
# tcpdump -v
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
23:14:53.372604 IP (tos 0x0, ttl 64, id 17534, offset 0, flags [none], proto UDP (17), length 384)
0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from b8:27:eb:64:2b:f2 (oui Unknown), length 356, xid 0x37bc3a64, secs 11906, Flags [none]
Client-Ethernet-Address b8:27:eb:64:2b:f2 (oui Unknown)
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
Client-ID Option 61, length 7: ether b8:27:eb:64:2b:f2
SLP-NA Option 80, length 0""
NOAUTO Option 116, length 1: Y
MSZ Option 57, length 2: 1472
Vendor-Class Option 60, length 56: "dhcpcd-6.11.5:Linux-4.14.34-hypriotos-v7+:armv7l:BCM2835"
Hostname Option 12, length 14: "test-client"
T145 Option 145, length 1: 1
Parameter-Request Option 55, length 15:
Subnet-Mask, Classless-Static-Route, Static-Route, Default-Gateway
Domain-Name-Server, Hostname, Domain-Name, MTU
BR, NTP, Lease-Time, Server-ID
RN, RB, Option 119
23:15:07.057241 IP (tos 0x0, ttl 64, id 26091, offset 0, flags [none], proto UDP (17), length 384)
0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:e0:4c:23:c2:22 (oui Unknown), length 356, xid 0x1b0502bb, secs 8250, Flags [none]
Client-Ethernet-Address 00:e0:4c:23:c2:22 (oui Unknown)
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
Client-ID Option 61, length 7: ether 00:e0:4c:23:c2:22
SLP-NA Option 80, length 0""
NOAUTO Option 116, length 1: Y
MSZ Option 57, length 2: 1472
Vendor-Class Option 60, length 56: "dhcpcd-6.11.5:Linux-4.14.34-hypriotos-v7+:armv7l:BCM2835"
Hostname Option 12, length 14: "gateway"
T145 Option 145, length 1: 1
Parameter-Request Option 55, length 15:
Subnet-Mask, Classless-Static-Route, Static-Route, Default-Gateway
Domain-Name-Server, Hostname, Domain-Name, MTU
BR, NTP, Lease-Time, Server-ID
RN, RB, Option 119#
^C
2 packets captured
2 packets received by filter
0 packets dropped by kernel
O que estou perdendo? O objetivo final é que todos aqueles na faixa 10.0.0.0/24 se conectem ao resto da internet por trás de um nat.