Mesh bridge forwarding

This commit is contained in:
Bob Mottram 2017-09-29 17:32:51 +01:00
parent 5ea411c113
commit 2cc77069ee
1 changed files with 28 additions and 0 deletions

View File

@ -164,6 +164,18 @@ function stop {
iptables -D INPUT -p tcp --dport 8942 -j ACCEPT iptables -D INPUT -p tcp --dport 8942 -j ACCEPT
iptables -D INPUT -p udp --dport 8942 -j ACCEPT iptables -D INPUT -p udp --dport 8942 -j ACCEPT
iptables -t nat -D POSTROUTING -o $EIFACE -j MASQUERADE
iptables -D FORWARD -i $EIFACE -o $IFACE -j ACCEPT -m state state RELATED,ESTABLISHED
iptables -D FORWARD -i $IFACE -o $EIFACE -j ACCEPT
if [ $IFACE_SECONDARY ]; then
iptables -D FORWARD -i $IFACE -o $IFACE_SECONDARY -j ACCEPT -m state state RELATED,ESTABLISHED
iptables -D FORWARD -i $IFACE_SECONDARY -o $IFACE -j ACCEPT
fi
echo 0 > /proc/sys/net/ipv4/ip_forward
sed -i 's|net.ipv4.ip_forward=.*|net.ipv4.ip_forward=0|g' /etc/sysctl.conf
systemctl restart network-manager systemctl restart network-manager
} }
@ -251,6 +263,7 @@ function start {
dhclient $BRIDGE dhclient $BRIDGE
fi fi
hotspot_enabled=
if [ $IFACE_SECONDARY ]; then if [ $IFACE_SECONDARY ]; then
if [[ $IFACE != $IFACE_SECONDARY ]]; then if [[ $IFACE != $IFACE_SECONDARY ]]; then
if [ -d /etc/hostapd ]; then if [ -d /etc/hostapd ]; then
@ -291,6 +304,7 @@ function start {
ifconfig $IFACE_SECONDARY up promisc ifconfig $IFACE_SECONDARY up promisc
#ifconfig $IFACE_SECONDARY auto-dhcp start #ifconfig $IFACE_SECONDARY auto-dhcp start
systemctl start hostapd systemctl start hostapd
hotspot_enabled=1
fi fi
fi fi
fi fi
@ -324,6 +338,20 @@ function start {
iptables -A INPUT -p tcp --dport 8942 -j ACCEPT iptables -A INPUT -p tcp --dport 8942 -j ACCEPT
iptables -A INPUT -p udp --dport 8942 -j ACCEPT iptables -A INPUT -p udp --dport 8942 -j ACCEPT
iptables -t nat -A POSTROUTING -o $EIFACE -j MASQUERADE
iptables -A FORWARD -i $EIFACE -o $IFACE -j ACCEPT -m state state RELATED,ESTABLISHED
iptables -A FORWARD -i $IFACE -o $EIFACE -j ACCEPT
if [ $hotspot_enabled ]; then
iptables -A FORWARD -i $IFACE -o $IFACE_SECONDARY -j ACCEPT -m state state RELATED,ESTABLISHED
iptables -A FORWARD -i $IFACE_SECONDARY -o $IFACE -j ACCEPT
fi
echo 1 > /proc/sys/net/ipv4/ip_forward
sed -i 's|# net.ipv4.ip_forward|net.ipv4.ip_forward|g' /etc/sysctl.conf
sed -i 's|#net.ipv4.ip_forward|net.ipv4.ip_forward|g' /etc/sysctl.conf
sed -i 's|net.ipv4.ip_forward.*|net.ipv4.ip_forward=1|g' /etc/sysctl.conf
systemctl restart avahi-daemon systemctl restart avahi-daemon
verify verify