Reconfigure Interface without "Setup"

Hey there,

is there another possibility to reconfigure an interface (red0 in my case) besides using the “setup”-command?

Background: I want to write a little script that automatically reconfigures an interface (ip-adress, netmask, gateway, etc.).

I found all those informations in “/var/ipfire/ethernet/settings” but editing that file and restarting the network-service did not seem to do the trick. Maybe I’m just missing something here. :slight_smile:

Background-Background (longer): I did some experimenting with a WWAN-module (Recommendation for WWAN-Module - #8 by lexuspolaris) and was successful in the end. :sunglasses:

The only problem left is, that I am not able (due to the lack of knowledge, obviously :crazy_face:) to make it work for the connected devices. Getting an IP adress from the provider, assigning it to red interface, creating some routes, everything worked out: But in the end, only the firewall itself could do pings and so on, but not the connected devices in green and blue.

And because I KNOW that I will not be able to figure out all the necessary steps in an acceptable amount of time, I created a workaround: I established a connection via console, copied the assigned IP, Netmask and Gateway from the Provider and configured the red-interface as “static” with the provided information

Works without any problems, but now I would like to “automate” it. :slight_smile:

Any help appreciated!

Greetings

P.S.: I KNOW that this is not even nearly a perfect solution. The best solution would be to implement the new “libmbim” library in IPFire in a way, that it could be used just like “libqmi” in the dial-up screen. But as I said earlier, I do not have the necessary skills to accomplish such a big thing. :slight_smile:

This is WAY beyond my understanding of IPFire inner working. I tried GPT4, but I cannot relay efficiently any useful information. However, you might get some inspiration to move forward. This is the link to the chat. You should read also the last message. If you make any progress, please let the community know.

I won’t keep it up for too long, so please take notes.

Good luck.

I believe that the file that needs to be modified is

/var/ipfire/dhcpc/dhcpcd-red0.info

However when testing make sure that you keep a backup copy of the original file plus have an IPFire backup stored off of IPFire.
I believe that this file is where the required info on IP, netmask, routers, DNS, lease time etc for the red0 interface end up being written. However I have not tested anything myself with this file so be cautious.

1 Like

1.Could you please share the Fireinfo profile link?
2.Could you please show the result of the console command
ifconfig | grep -o '^[^ ][^ ]*'

Best

1 Like

If you can access the internet from IPFire, but not from the devices in GREEN and BLUE, I don’t think the problem is the RED configuration.

Therefore we need some more informations.

  • What kind of internet access do you use?
  • How is the connection defined, static/dialup(DSL)/DHCP ?
  • What routing settings did you define besides the standard settings of IPFire?

According to the informations given till now, IMO there is no need for “Reconfiguration without setup”.

1 Like

From my reading if this and the last post you linked above. Perhaps your problem lies here.

Would not a static Mac address assignment
Be a better solution for your WWAN card.
The it would use DHCP and reconnect.
Your WAN / Global ip would change.
But so does mine.
Your configuration / setup is probably tied more so to your WAN / WWAN mac address.
So my thought is a fixed MAC addresses
Is probably the correct path.

@hvacguy , good find!

I didn’t realise the behaviour.
But to identify a connection the provider needs an unambiguous ‘name’ of the client device. Usually this realised by chosing the MAC address which is by definition unique.
All ‘identity hiding means’ are counterproductive!

For example in the cable internet ( DOCSIS ) world, most providers don’t tolerate a change on-the-fly. You have to restart the modem, some providers demand a call to the service center.

1 Like

You have to shutdown red before editing “/var/ipfire/ethernet/settings” with “connsheduler hangup”
edit the file
and then run “connsheduler dial”

If you edit the file without shutdown red first the scripts not found the needed setting for shoutdown anymore.

3 Likes

Hey guys,

first of all, I’m deeply sorry for not responding earlier but I was busy the whole weekend with tweaking and documenting. :nerd_face:

After all it was my fault. To speed things up, I just deleted the “settings” under “/var/ipfire/ethernet” and created a new one, not recognizing that the new one has a different owner (“root” instead of “nobody”). That’s why it would not load the correct interface-settings after restarting the network.

In the end everything went out great :hugs:. I wrote a script that:

shuts down red0 and wwan0
renames red0 to eth0 (in my case) and then wwan0 to red0
brings up the “new” red0
connects red0 with the ISP via mbim-cli
reads out the dynamically created MAC and the IP/suffix and gateway assigned by the provider
creates the netaddress and calculates the “long” netmask from the suffix
assigns all the necessary addresses to the red interface (writes the information in the settings-file)
flushes the ip route of the red interface (the old default and static routes)
and restarts the network, whereby it creates the new default and static routes for red

After about 20 seconds the whole network is up again, all the routes are set and everything just works.

I wrote another script which switches it back to “normal”, which also works flawlessly.

This solution may sound a bit odd because red is now still set to “static” although it is actually a dial-up connection. But when I change red to Dial-Up / PPPoE in the setup screen, then the red interface dissappears from the firewall settings (it is still existent in the zone-configuration but not in the firewall-configuration). When I then connect to the ISP only the firewall itself can communicate with the internet (ping works, wget works, everything) but none of the connected devices.

Maybe it is because the red interface has no IP-address yet when freshly switched to Dial-Up / PPPoE but running dhcpd after the connection with the ISP is established like you would with QMI did not seem to work.

Anyway, my solution works and I’m happy with that. :slight_smile: Maybe I will write another script / fcron-job, which checks for connection state and automatically reconnects in the case of a disconnect but for now I’m good. :sunglasses:

Another thing could be to “save” the MAC-address of the WWAN-interface and write it back after a restart of IPFire to kind of “disable” the dynamic switching. But usually you would not restart the device everyday and a new IP-address every now and then is not bad either. :wink:

Anyway, thanks for all your answers!

Have a nice day!

1 Like