[FS#283] NAT Loopback ("reflections") not working correctly.
LEDE Bugs
lede-bugs at lists.infradead.org
Tue Nov 29 09:27:06 PST 2016
The following task has a new comment added:
FS#283 - NAT Loopback ("reflections") not working correctly.
User who did this - schoerg (schoerg)
----------
Thank you, I tried it somewhat:
#!/bin/sh
mask="0"
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
}
#DBG=-v
proto_mbim_init_config() {
available=1
no_device=1
proto_config_add_string "device:device"
proto_config_add_string apn
proto_config_add_string pincode
proto_config_add_string delay
proto_config_add_string auth
proto_config_add_string username
proto_config_add_string password
}
# https://stackoverflow.com/questions/20762575
cdr2mask ()
{
# Number of args to shift, 255..255, first non-255 byte, zeroes
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 /tmp/ip
IP=$(cat /tmp/ip |grep ipv4address |grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
NM=$(cat /tmp/ip |grep ipv4address |grep -o '.\{2\}$')
GW=$(cat /tmp/ip |grep ipv4gateway |grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
DNS=$(cat /tmp/ip |grep ipv4dnsserver |grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" |head -1)
cdr2mask $NM
echo "IP: $IP $mask"
echo "GW: $GW"
echo "DNS: $DNS"
uci_set_state network $interface tid "$tid"
echo "mbim[$$]" "Connected, setting IP"
proto_init_update "$ifname" 1
proto_send_update "$interface"
json_init
json_add_string name "${interface}_4"
json_add_string ifname "@$interface"
json_add_string proto "static"
ifconfig wwan0 $IP netmask $mask
ip route add default dev wwan0
proto_add_ipv4_address $IP $mask
proto_add_ipv4_route 0.0.0.0 0 $GW
proto_send_update wan
echo "nameserver $DNS" >> /tmp/resolv.conf.auto
echo "nameserver $DNS" >> /etc/resolv.conf
#proto_init_update wwan0
#proto_add_ipv4_address $IP $mask
#proto_add_ipv4_route 0.0.0.0 0 $GW
#proto_send_update wan
return 0
}
proto_mbim_setup() {
local ret
_proto_mbim_setup $@
ret=$?
[ "$ret" = 0 ] || {
logger "mbim bringup failed, retry in 15s"
sleep 15
}
return $rt
}
proto_mbim_teardown() {
local interface="$1"
local device
json_get_vars device
local tid=$(uci_get_state network $interface tid)
[ -n "$ctl_device" ] && device=$ctl_device
echo "mbim[$$]" "Stopping network"
[ -n "$tid" ] && {
umbim $DBG -t$tid -d "$device" disconnect
uci_revert_state network $interface tid
}
proto_init_update "*" 0
proto_send_update "$interface"
}
[ -n "$INCLUDE_ONLY" ] || add_protocol mbim
The changes are very sloppy, but work. Not sure on where to add the proto_ stuff.
----------
More information can be found at the following URL:
https://bugs.lede-project.org/index.php?do=details&task_id=283#comment980
More information about the lede-bugs
mailing list