F5F Stay Refreshed Power Users Networks Move a web server between different network environments

Move a web server between different network environments

Move a web server between different network environments

C
cocochip50
Member
193
11-18-2018, 08:19 AM
#1
Hi everyone. I'm using a laptop as my home assistant setup (Debian with supervisor) for my living space. I have a DWM-222 4G LTE stick connected via USB (interface `usb0`, IP `192.168.0.2`) and my home network (interface `enp5s0`, IP `192.168.1.100`). I need to set up forwarding so that I can reach the LTE stick's web interface (`192.168.0.1:80`) from my local network, specifically using the URL `http://192.168.1.100:8080`. I'm using a UFW firewall and have tried several methods:

- Enabled `ip_forward` in `nano /etc/sysctl.conf`
- Added port forwarding with UFW:
```
ufw route allow proto tcp from any to 192.168.0.1 port 80 forward to 192.168.1.100 port 8080
```
- Configured iptables instead:
```
iptables -t nat -A PREROUTING -i enp5s0 -p tcp --dport 8080 -j DNAT --to-destination 192.168.0.1:80
iptables -A FORWARD -i enp5s0 -o usb0 -p tcp --dport 80 -d 192.168.0.1 -j ACCEPT
```

But unfortunately, it doesn't work as expected. I'm still trying to figure out what might be wrong. Any suggestions?
C
cocochip50
11-18-2018, 08:19 AM #1

Hi everyone. I'm using a laptop as my home assistant setup (Debian with supervisor) for my living space. I have a DWM-222 4G LTE stick connected via USB (interface `usb0`, IP `192.168.0.2`) and my home network (interface `enp5s0`, IP `192.168.1.100`). I need to set up forwarding so that I can reach the LTE stick's web interface (`192.168.0.1:80`) from my local network, specifically using the URL `http://192.168.1.100:8080`. I'm using a UFW firewall and have tried several methods:

- Enabled `ip_forward` in `nano /etc/sysctl.conf`
- Added port forwarding with UFW:
```
ufw route allow proto tcp from any to 192.168.0.1 port 80 forward to 192.168.1.100 port 8080
```
- Configured iptables instead:
```
iptables -t nat -A PREROUTING -i enp5s0 -p tcp --dport 8080 -j DNAT --to-destination 192.168.0.1:80
iptables -A FORWARD -i enp5s0 -o usb0 -p tcp --dport 80 -d 192.168.0.1 -j ACCEPT
```

But unfortunately, it doesn't work as expected. I'm still trying to figure out what might be wrong. Any suggestions?

C
Creeperguy406
Junior Member
4
11-19-2018, 04:34 AM
#2
To connect various networks, you require a device that belongs to both (such as a router). This router must be configured as the default gateway for your other machines within the remote network's IP range. When a device on 192.168.1.x needs to communicate with one on 192.168.0.x, it will route the request through its default gateway. Because the gateway participates in both networks, it can forward the message and deliver the reply.
C
Creeperguy406
11-19-2018, 04:34 AM #2

To connect various networks, you require a device that belongs to both (such as a router). This router must be configured as the default gateway for your other machines within the remote network's IP range. When a device on 192.168.1.x needs to communicate with one on 192.168.0.x, it will route the request through its default gateway. Because the gateway participates in both networks, it can forward the message and deliver the reply.

S
SkyMaster280
Member
214
11-19-2018, 12:43 PM
#3
Port forwarding is likely needed since the device you're using is behind NAT and needs external access. The client doesn't realize it's leaving the local network. Firewall settings aren't clear, but a POSTROUTING rule might help route responses through the NAT.
S
SkyMaster280
11-19-2018, 12:43 PM #3

Port forwarding is likely needed since the device you're using is behind NAT and needs external access. The client doesn't realize it's leaving the local network. Firewall settings aren't clear, but a POSTROUTING rule might help route responses through the NAT.