Sometimes I need a secondary gateway in my network, or simply want to provide Internet access for another device using my Linux box. The trick is simple, in this example, I am using a Raspberry Pi 4B with Rasbian 10 installation.
Set the interface address to static and assign a network segment to it, in this example, 192.168.168.1
is assigned to eth0
, with network mask 255.255.255.0
.
(https://www.raspberrypi.org/documentation/configuration/tcpip/)[Raspberry Pi Document: TCP/IP networking]
edit /etc/dhcpcd.conf
1 |
|
edit /etc/sysctl.conf
Add the following line:
1 |
|
Install iptables-persistent
so the rules can persist between reboots.
1 |
|
edit /etc/iptables/rules.v4
, assume wlan0
is the interface used to access the Internet.
1 |
|
Install with:
1 |
|
edit /etc/dnsmasq.conf
:
1 |
|