Context
- Some devices (e.g. NAS, lab hardware, controllers) don’t have WiFi.
- Instead of running a long Ethernet cable to the router, a computer can act as a gateway/bridge.
- Example here: a NAS, but could be any Ethernet device.
Network Setup
- Main LAN:
192.168.8.0/24 (WiFi, router, laptops, cluster nodes)
- Isolated subnet:
192.168.0.0/24 (device connected directly to PC via Ethernet)
- The computer sits in between and provides:
- DHCP (assign IP to device)
- NAT (give device internet access)
- Forwarding (route packets between interfaces)
- Optional port forwards (make device reachable from main LAN)
graph LR
Internet([Internet])
Router[Router<br/>192.168.8.1]
subgraph "Main LAN: 192.168.8.0/24"
Node0[Gateway PC<br/>192.168.8.200<br/>WiFi: wlp2s0]
Node1[Node1<br/>192.168.8.201]
Laptop[Laptop<br/>192.168.8.***]
Phone[Phone<br/>192.168.8.***]
end
subgraph "Isolated Subnet: 192.168.0.0/24"
Device[Ethernet Device<br/>192.168.0.3<br/>example.local]
end
subgraph "Bridge Services"
DHCP[dnsmasq DHCP]
NAT[iptables NAT]
PortForward[Port Forward<br/>9123 to 80]
end
Internet --> Router
Router -.WiFi.- Node0
Router -.WiFi.- Node1
Router -.WiFi.- Laptop
Router -.WiFi.- Phone
Node0 ---|Ethernet eno1| Device
Node0 --> DHCP
Node0 --> NAT
Node0 --> PortForward
DHCP -.assigns IP.- Device
NAT -.internet access.- Device
Laptop -.port 9123.- PortForward
Phone -.port 9123.- PortForward
PortForward --> Device
classDef device fill:#e1f5fe
classDef computer fill:#f3e5f5
classDef service fill:#fff3e0
class Device device
class Node0 computer
class DHCP,NAT,PortForward service
Commands
Bring up Ethernet + assign IP
sudo ip link set eno1 up
sudo ip addr add 192.168.0.1/24 dev eno1
Enable IP forwarding
sudo sysctl net.ipv4.ip_forward=1
NAT + forwarding rules
sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o wlp2s0 -j MASQUERADE
sudo iptables -A FORWARD -i eno1 -o wlp2s0 -j ACCEPT
sudo iptables -A FORWARD -i wlp2s0 -o eno1 -m state --state RELATED,ESTABLISHED -j ACCEPT
DHCP with dnsmasq
sudo apt install dnsmasq
echo "interface=eno1
dhcp-range=192.168.0.2,192.168.0.10,12h
dhcp-option=3,192.168.0.1
dhcp-option=6,8.8.8.8
port=0" | sudo tee /etc/dnsmasq.d/bridge.conf
sudo systemctl restart dnsmasq
Optional: port forwarding
sudo iptables -t nat -A PREROUTING -p tcp --dport 9123 -j DNAT --to-destination 192.168.0.3:80
Quick Checks
nmap -sn 192.168.0.0/24 # find device
ping 192.168.0.3 # check connectivity
curl -I http://192.168.0.3 # test web UI
Notes / Uses
- From main LAN: reach device via
http://192.168.8.200:9123 (or whichever port you forward).
- From local subnet: use its direct IP (
192.168.0.3).
- Device gets internet via PC → WiFi.
- Good for: NAS, smart-home controllers, dev boards, old lab equipment, etc.