Answer the question
In order to leave comments, you need to log in
How to properly set up bridge mode on Raspberry Pi?
Hello colleagues! I really need your help in setting up a network on the Raspberry Pi.
We have:
1. Raspberry Pi Zero W;
2. Huawei E3372h LTE USB modem with advanced web interface;
3. A SIM card with a white ip-address (namely, with a white one, it pings calmly from the Internet)
4. A web application written in Flask. The NginX + Gunicorn bundle is used as a server. All this economy is deployed on the Raspberry Pi.
Required:
Configure the raspberry so that it distributes Wi-Fi, while connecting to it has access to the web application. Access to the web application is also needed from the network using the IP address of the SIM card.
Because Huawei E3372h already has a DHCP server, and the default modem IP address (192.168.8.1) is needed for the web application to work, it was decided to set the raspberry to bridge mode. In this case, the DHCP server on the modem distributes addresses in the range 192.168.8.100 - 192.168.8.150. To set up this bundle, I used the following manual: Manual . The only thing I added: I registered the setting of a static ip-address for Raspberry in /etc/network/interfaces as follows:
auto br0
iface br0 inet static
bridge_ports eth0 wlan0
address 192.168.8.151
netmask 255.255.255.0
network 192.168.8.0
broadcast 192.168.1.255
. sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
iptables-restore < /etc/iptables.ipv4.nat
. Answer the question
In order to leave comments, you need to log in
I raised this modem, but I did not touch this subnet 192.168.8.0/24 which is from the modem but only used its interface (dhcp did not use it). Further configured dhcp iptables and still net.ipv4.ip_forward=1 is obligatory. It was configured on odroid-c2.
But without the white address is true.
#!/bin/bash
LAN="eth0"
WAN="usbnet0"
# flush tables
iptables -F
iptables -t nat -F
# apply routing
iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
iptables -A FORWARD - i $WAN -o $LAN -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i $LAN -o $WAN -j ACCEPT
But I won’t tell you how to set up the rules in order to forward ports from a white address to your nginx. It turns out in any way? What is this operator? Why such a bundle (mobile Internet and an application on it)?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question