Obtain Specific Client IP Variation

Hello everyone,

Currently, I am using the Echolife HG533 router with OpenWRT installed, where I utilize the USB LTE modem E3276 as the source of internet connection.

Everything is working normally, but I would like to inquire if there is any software, IPK, or similar solution that can search for client IPs based on my criteria.

Here's what I mean: Every time OpenWRT reboots, I want it to automatically perform a dial-up, and my ISP typically provides client IPs in the pattern xx.xx., while I desire an IP in the format xx.xxx., for example, 10.154.135.1, whereas the IPs I usually receive are like 10.16.2.145.

The difference is that the second block of numbers consists of three digits instead of two.

So, my question is, is there any IPK software for OpenWRT that can achieve this, i.e., perform dial-up until it obtains the desired IP variation?

Thank you.

So you want a wardialer software to keep trying the same number?

Like: https://en.m.wikipedia.org/wiki/Wardialing

Since obtaining the IP under the control of the ISP and doing so is a form of denial of service, I would guess no.

You've never seen movie War Games before. :wink:

  • Have you tried just assigning the IP you desire?
  • Are there cosmetic or technical reasons you want a particular IP?
1 Like

Oh, so it's called wardialing? I'm not familiar with this, but I'll research it later.

I have tried using a fixed IP, but dial-up couldn't be established.

The reason I want to use IPs with the mentioned variations is that these IPs are 60% more stable and faster. As an example, I can download at a speed of 2 Mbps using IDM, but the IP xx.xx only reaches around 800 KBps and frequently experiences timeouts (failed to load web pages).

it wasn't meant for illegal activity

1 Like

[Solved] How to refresh Internet connection if assigned private IP - #8 by vgaetera

case ${WAN_ADDR} in
(??.???.*) exit 0 ;;
esac
3 Likes

You can use @vgaetera's script but instead of matching on "10" use something like:

grep -oqE "[0-9]{2}\.[0-9]{3}.*" 
3 Likes

Perhaps then:

cat << "EOF" > /etc/hotplug.d/iface/10-fix-wan-ip
. /lib/functions/network.sh
network_flush_cache
network_find_wan NET_IF
network_get_ipaddr NET_ADDR "${NET_IF}"
if [ "${ACTION}" = "ifup" ] \
&& [ "${INTERFACE}" = "${NET_IF}" ] \
&& echo "${NET_ADDR}" | grep -oqE "^[0-9]{2}\.[0-9]{2}.*" 
then
    sleep 10
    ifup "${NET_IF}"
fi
EOF
1 Like

Hi @lynx

I have exactly the same situation as OP described ,my apology if I sound silly...this are my first time using openwrt..

I've downloaded custom openwrt into my set top box and Atm currently using it

But how we use the script?

We log into ssh and then copy paste the code above?

Thank you

There are very few STBs (or maybe even none) that are supported by the official OpenWrt project... you mentioned custom, so you may need to ask in the support channels for that custom OpenWrt (as it may be materially different than the official one).

Since the script from @Lynx is just a typical linux script, you would save it to a file, add execute permissions, and run it from the command line (so, yes... typically that means within an ssh session). It should operate like any other linux script in that regard, unless the customized version of OpenWrt causes it to fail to run properly. If you need help with how to create and run a linux script, you can easily find tutorials on the web with a simple search.

Hi @pseheman,

Thank you for providing assistance to beginners like me. Yup, I downloaded the custom OpenWRT firmware from the internet. I suspect this customization is because of what you mentioned earlier, which is that OpenWRT doesn't support the ZXV10 B860H STB.

Im using USB LTE modem Huawei e3976

I've followed the steps as you explained above, but it seems there's no change whatsoever when I execute the script. My client's IP still remains unchanged.

shell

chmod +x /etc/hotplug.d/iface/10-fix-wan-ip
./10-fix-wan-ip

Could you help me take a quick look at what might be wrong? I'll provide the details if that can be of assistance.

Bellow is the web interface detail

result of ifconfig -a

root@REYRE-STB:/etc/hotplug.d/iface# ifconfig -a
br-lan    Link encap:Ethernet  HWaddr 00:AC:EF:3F:C0:FF
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::2ac:efff:fe3f:c0ff/64 Scope:Link
          inet6 addr: fd32:2400:40b9::1/60 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19223 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25606 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2498779 (2.3 MiB)  TX bytes:31075745 (29.6 MiB)

eth0      Link encap:Ethernet  HWaddr 00:AC:EF:3F:C0:FF
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:71981 errors:0 dropped:8 overruns:0 frame:0
          TX packets:105797 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10081861 (9.6 MiB)  TX bytes:123231955 (117.5 MiB)
          Interrupt:40

ip6tnl0   Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          NOARP  MTU:1452  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:4096  Metric:1
          RX packets:2690 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2690 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:225528 (220.2 KiB)  TX bytes:225528 (220.2 KiB)

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tunl0     Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 58:5F:F6:08:BC:3B
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:618 errors:0 dropped:0 overruns:0 frame:0
          TX packets:664 errors:0 dropped:21 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:220141 (214.9 KiB)

wwan0     Link encap:Ethernet  HWaddr 0C:5B:8F:27:9A:64
          inet addr:10.7.174.24  Bcast:10.7.174.31  Mask:255.255.255.240
          inet6 addr: fe80::e5b:8fff:fe27:9a64/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:96939 errors:0 dropped:0 overruns:0 frame:0
          TX packets:66139 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:117188627 (111.7 MiB)  TX bytes:178078364 (169.8 MiB)

interface menu

dial setting

The script essentially asks for another ip. Beyond that, it can’t do anything more. It is the upstream device/service that is actually responsible for issuing an ip, and it is that system that would need to be willing and able to give you a different one. It’s like you sent back your coffee because you wanted a cappuccino, but the place only has (or is only willing to make) regular drip coffee. Your choice is coffee or coffee.

And, as you know since you downloaded a customized version of OpenWrt, that is not the same as openwrt from the official project. You’ll have to ask the maintainers of that custom build for further assistance since it, by definition, must be different than openwrt and therefore cannot be assumed to operate in the same way.

1 Like

If you issue ifdown and then ifup on the wan interface does ifconfig report a new IP each time? If I wanted to generate the script I'd first work out how to do it manually. Then work out how to script it.

2 Likes

If you issue ifdown and then ifup on the wan interface does ifconfig report a new IP each time? If I wanted to generate the script I'd first work out how to do it manually. Then work out how to script it.

no, it doesn't report new ip ..if i click manually restart on HILINK interface i do get new ip..system log are something like this

Sun Aug 27 21:37:49 2023 daemon.notice netifd: hilink (17756): sending -> AT^NDISDUP=1,0
Sun Aug 27 21:37:49 2023 daemon.notice netifd: hilink (17756): Command failed: Permission denied
Sun Aug 27 21:37:49 2023 daemon.notice netifd: Interface 'hilink' is now down
Sun Aug 27 21:37:49 2023 daemon.notice netifd: Interface 'hilink' is setting up now
Sun Aug 27 21:37:50 2023 user.notice mwan3-hotplug[17892]: mwan3 hotplug on hilink not called because interface disabled
Sun Aug 27 21:37:51 2023 kern.warn kernel: [  680.707576] RTL871X: cfg80211_rtw_change_beacon(wlan0)
Sun Aug 27 21:37:51 2023 kern.warn kernel: [  680.714975] RTL871X: rtw_add_beacon beacon_head_len=59, beacon_tail_len=91
Sun Aug 27 21:37:51 2023 kern.warn kernel: [  680.723626] RTL871X: rtw_check_beacon_data, len=126
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.730489] RTL871X: rtw_ap_chbw_decision(wlan0) ld_sta_num:0, lg_sta_num0, ap_num:0
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.738185] RTL871X: rtw_ap_chbw_decision(wlan0) req: 11,0,0
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.745579] RTL871X: rtw_ap_chbw_decision(wlan0) dec: 11,0,0
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.751143] RTL871X: HW_VAR_BASIC_RATE: 0x150 -> 0x15f -> 0x15f
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.757068] RTL871X: supp_mcs_set = 00, 00, 00, rf_type=255, tx_ra_bitmap=0000000000000150
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.767163] RTL871X: rtw_get_tx_nss: 1 SS, rf_type=3
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.774551] RTL871X: ### Set STA_(1) info ###
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.780804] RTL871X: update_bmc_sta=> mac_id:1 , raid:7 , bitmap=0x0000000000000150
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.788451] RTL871X: rtl8188f_Add_RateATid(): mac_id=1 raid=0x7 bw=0 mask=0x150
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.795700] RTL871X: rtl8188f_set_FwMacIdConfig_cmd(): mac_id=1 raid=0x7 bw=0 mask=0x150
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.844378] RTL871X: cfg80211_rtw_change_bss(wlan0)
Sun Aug 27 21:37:52 2023 kern.warn kernel: [  680.851197] RTL871X: HwRateToMRate(): Non supported Rate [ff]!!!
Sun Aug 27 21:37:52 2023 daemon.notice netifd: hilink (17893): sending -> AT
Sun Aug 27 21:37:52 2023 daemon.notice netifd: hilink (17893): sending -> ATZ
Sun Aug 27 21:37:53 2023 daemon.notice netifd: hilink (17893): sending -> ATQ0
Sun Aug 27 21:37:53 2023 daemon.notice netifd: hilink (17893): sending -> ATV1
Sun Aug 27 21:37:54 2023 daemon.notice netifd: hilink (17893): sending -> ATE1
Sun Aug 27 21:37:55 2023 daemon.notice netifd: hilink (17893): sending -> ATS0=0
Sun Aug 27 21:37:55 2023 daemon.notice netifd: hilink (17893): sending -> AT+CGDCONT=1,"IP","internet"
Sun Aug 27 21:37:56 2023 kern.warn kernel: [  685.062394] RTL871X: HwRateToMRate(): Non supported Rate [ff]!!!
Sun Aug 27 21:37:56 2023 daemon.notice netifd: hilink (17893): Configuring modem
Sun Aug 27 21:37:56 2023 daemon.notice netifd: hilink (17893): Starting network hilink
Sun Aug 27 21:37:56 2023 daemon.notice netifd: hilink (17893): Connecting modem
Sun Aug 27 21:37:56 2023 daemon.notice netifd: hilink (17893): sending -> AT^NDISDUP=1,1,"internet"
Sun Aug 27 21:37:57 2023 daemon.notice netifd: hilink (17893): Setting up wwan0
Sun Aug 27 21:37:57 2023 daemon.notice netifd: Network alias 'wwan0' link is up
Sun Aug 27 21:37:57 2023 daemon.notice netifd: Interface 'hilink' is now up
Sun Aug 27 21:37:57 2023 daemon.notice netifd: Interface 'hilink_4' is enabled
Sun Aug 27 21:37:57 2023 daemon.notice netifd: Interface 'hilink_4' has link connectivity
Sun Aug 27 21:37:57 2023 daemon.notice netifd: Interface 'hilink_4' is setting up now
Sun Aug 27 21:37:57 2023 daemon.notice netifd: hilink_4 (18095): udhcpc: started, v1.33.2
Sun Aug 27 21:37:57 2023 daemon.notice netifd: hilink_4 (18095): udhcpc: sending discover

i tried ifdown wwan hilink and then ifconfig wwan0 but ip remain unchanged ...how do i know on which interface my USB stick modem attached to?

--edit--

i tried command

root@AEmR-STB:~# ifdown hilink
root@AEmR-STB:~# ifup hilink
root@AEmR-STB:~# ifconfig wwan0
wwan0     Link encap:Ethernet  HWaddr 0C:5B:8F:27:9A:64
          inet6 addr: fe80::e5b:8fff:fe27:9a64/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26574 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20566 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:27036497 (25.7 MiB)  TX bytes:3159418 (3.0 MiB)

ifdown hilink did change my ip

So you have the basics to write script to automate this.

ok ..thank lynx

i understand the logic now...bring the interface down ,bring the interface up , check new ip and if the ip matched the script should stop the loop...

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.