LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-04-2020, 08:39 PM   #1
armars
LQ Newbie
 
Registered: Jul 2020
Posts: 5

Rep: Reputation: Disabled
Question How to refresh PPPoE Internet connection if assigned private IP (OpenWRT)


Hello everyone

I am new to linux

I am using linux based Openwrt
I tried ask this question in OpenWRT forum, but there is no answer yet
---------------
I am connecting to my internet provider through PPPoE connection

provider assigns me IP dynamically

but provider sometimes assigns private IP (10.x.x.x) instead of public
(I mean that my provider assigns randomly private or public IP)
here is my question

how can I configure openwrt to renew connection automatically if private IP is assigned ??
----------------------------
I mean after connection established provider assigned me IP
openwrt checks that IP
if IP is private
openwrt closes connection (or reboots openwrt)
waits few minutes connects to provider again
until public IP is not assigned by provider
-------------------------
I am using OpenWrt 19.07
-------------------------

As I understand better way to do it is write some script in /etc/ppp/ip-up

thanks in advance

Last edited by armars; 07-04-2020 at 08:51 PM.
 
Old 07-04-2020, 10:54 PM   #2
tinfoil3d
Member
 
Registered: Apr 2020
Location: Japan/RJCC
Distribution: debian, lfs, whatever else i need in qemu
Posts: 231

Rep: Reputation: Disabled
Yeah, that's right, you'd need something like
Code:
ip a show $IFACE | grep -q 'inet 10\.' && do-something-to-restart-this-interface
in if-up.d or as you mention something similar in /etc/ppp/ip-up if that's getting called on your system.
 
Old 07-05-2020, 04:48 AM   #3
armars
LQ Newbie
 
Registered: Jul 2020
Posts: 5

Original Poster
Rep: Reputation: Disabled
thanks for answer

man pppd says

Quote:
/etc/ppp/ip-up

A program or script that is executed when the link is available for sending and receiving IP packets (that is, IPCP has come up). It is executed with six command-line arguments: interface-name tty-device speed local-IP-address remote-IP-address ipparam.
I assume assigned IP address should be $4 (local-IP-address)

---------------

most important for me is do-something-to-restart-this-interface
so what I can write in /etc/ppp/ip-up to restart that pppoe connection

I would greatly appreciate any help
 
Old 07-05-2020, 06:08 AM   #4
tinfoil3d
Member
 
Registered: Apr 2020
Location: Japan/RJCC
Distribution: debian, lfs, whatever else i need in qemu
Posts: 231

Rep: Reputation: Disabled
Right. Well, how do you start it usually? try that command with restart instead of start for example and exit 0 immediately afterwards.
 
Old 07-05-2020, 06:52 AM   #5
armars
LQ Newbie
 
Registered: Jul 2020
Posts: 5

Original Poster
Rep: Reputation: Disabled
I am new to linux

I am configuring openwrt through web based gui (luci) (as well as pppoe connection to my provider )

as in regular routers

also pppoe is configured with keepalive option (I dont push button to connect or disconnect)


==================
but as I find out after reading a lot of info on internet

pppd daemon runs /etc/ppp/ip-up script every time when connection is established
 
Old 07-05-2020, 07:06 AM   #6
armars
LQ Newbie
 
Registered: Jul 2020
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
NOTES
These signals affect pppd behavior:
SIGINT, SIGTERM

Terminate the link, restore the serial device settings and exit.

SIGHUP

Terminate the link, restore the serial device settings and close the serial device. If the persist or demand option is specified, pppd attempts to reopen the serial device and start another connection after the holdoff period. Otherwise pppd exits. If received during the holdoff period, SIGHUP causes pppd to end the holdoff period immediately.
I found this in notes section of "man pppd"

if this can help
please write how
I dont know what are signals

https://man.cx/pppd

Last edited by armars; 07-05-2020 at 07:13 AM.
 
Old 07-05-2020, 08:46 AM   #7
tinfoil3d
Member
 
Registered: Apr 2020
Location: Japan/RJCC
Distribution: debian, lfs, whatever else i need in qemu
Posts: 231

Rep: Reputation: Disabled
you can send the signal listed to the ppp process like this
Code:
killall -HUP pppd
or if that doesn't do anything or command not found
Code:
kill -HUP `pidof pppd`
if neither result in restart, please paste what they both produce, along with
Code:
ps uaxwf
# or if it doesn't like options and returns an error try this instead
ps wl
# or if this doesn't like it too
ps w
when ppp is up.

You're new to linux but you'll be fine if you managed to figure out if-up and read the man. Signals are sent to processes in linux using "kill" command. SIGHUP can be shortened in "kill -HUP <pid>" or if you manage to remember the most basic signal numbers, it's "kill -1 <pid>" which makes life even easier(but it's not portable if you'd write scripts for other OSes in future).
 
Old 07-05-2020, 09:25 PM   #8
armars
LQ Newbie
 
Registered: Jul 2020
Posts: 5

Original Poster
Rep: Reputation: Disabled
thank you I will try

in openwrt forum user vgaetera wrote script for me

Code:
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" -a "${INTERFACE}" = "${NET_IF}" -a "${NET_ADDR%%.*}" = "10" ]
then
    sleep 10
    ifup "${NET_IF}"
fi
EOF

I want not only copy paste, but understand to make some changes in script when I need

1st simple question is why EOF in the end of script (I see it first time)


and all code is hard to understand for me
currently I read book The Linux Command Line W. Shotts

hope it will help me understand

but if you can give me directions understand this quicker I will appreciate

I uploaded network.sh from my openwrt here as txt file
Attached Files
File Type: txt network.sh.txt (7.9 KB, 0 views)
 
Old 07-05-2020, 11:37 PM   #9
tinfoil3d
Member
 
Registered: Apr 2020
Location: Japan/RJCC
Distribution: debian, lfs, whatever else i need in qemu
Posts: 231

Rep: Reputation: Disabled
EOF doesn't have to do anything with contents of the script, it's called heredoc, https://tldp.org/LDP/abs/html/here-docs.html
I didn't use openwrt myself but this user apparently uses the proper scripting designed for that particular os, utilizing it's scripts, so I'd say try that.
dot /lib/func.. would source, or load, the specified file into the current shell instance, that's probably where these network_* functions come from, they're probably not a commands you can find in the PATH.
${...} are variables, probably provided from pppd running this script, so upon checking that action is "ifup" and interface is wan(found and set by network_find_wan function) and it's first octet is 10 it sleeps 10 seconds and calls ifup on wan inteface again. I don't know if that's how it's supposed to work but probably it is, so try that.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigned static IP through yast but no internet connection (Hetzner Cloud) Faizan Khan Linux - Networking 1 07-30-2019 01:40 AM
Assigned static IP through yast but no internet connection (Hetzner Cloud) Faizan Khan SUSE / openSUSE 4 07-29-2019 05:22 AM
Missing /var/run/pppoe.conf-pppoe.pid.pppoe file acraig Debian 2 11-02-2010 07:24 PM
dvd has no URL assigned, so I can't play dvd's(no url assigned is the error message) Zych Linux - Newbie 3 08-01-2010 07:26 AM
adsl-status can't read pppoe PID file with rp-pppoe program setup Smarvy Linux - Newbie 2 03-13-2004 11:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration