Recently transferred from SLAX environment to Porteus and struggling with something that used to work
- perhaps I was abusing the system and getting away with it before!
I want to be able to switch operation (live) from having an allocated DHCP address to setting my own ... then when required, swap back again
e.g.
Start with DHCP allocated IP and use on one network; then connect to alternative network & select IP of say 100.0.0.10; then connect back to original and re-enable DHCP again
Used to do this using commands ....
To disable DHCP and define my own IP
dhcpcd -k eth0
sleep 2
ifconfig eth0 up
ifconfig eth0 100.0.0.1
Then to re-enable DHCP:
ifconfig eth0 up
dhcpcd eth0
ifconfig eth0 up
Note: I had to include the 'up' commands to ensure the interface always came up correctly.
However, this does not work under Porteus. Although the manually set IP is allocated, it does not stick. It goes back to the automatically assigned IP again.
Any clues or suggestions please
Many Thanks
John
DHCPCD - re-allocate IP
-
- White ninja
- Posts: 18
- Joined: 10 Jul 2012, 07:21
- Location: UK
- fanthom
- Moderator Team
- Posts: 5591
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Re: DHCPCD - re-allocate IP
hi OldAndWeary,
please create two profiles in Network Manager: one for static IP and one for dynamic IP.
now move them in/out of /etc/NetworkManager/system-connections folder with a script or command.
tested and works here.
please create two profiles in Network Manager: one for static IP and one for dynamic IP.
now move them in/out of /etc/NetworkManager/system-connections folder with a script or command.
tested and works here.
Please add [Solved] to your thread title if the solution was found.
- brokenman
- Site Admin
- Posts: 6104
- Joined: 27 Dec 2010, 03:50
- Distribution: Porteus v4 all desktops
- Location: Brazil
- Contact:
Re: DHCPCD - re-allocate IP
How are you actually connecting to the network? Do you use networkmanager or are you using wpa_supplicant directly through a script?
How do i become super user?
Wear your underpants on the outside and put on a cape.
Wear your underpants on the outside and put on a cape.
-
- White ninja
- Posts: 18
- Joined: 10 Jul 2012, 07:21
- Location: UK
Re: DHCPCD - re-allocate IP
Many Thanks to both fanthom and brokenman for replying.
I had got to the same conclusion as fanthom that I could probably 'play' with the /etc/NetworkManager/system-connections folder contents
... at least that's what I have been trying to script.
I'm very pleased to hear that this should work.
In fact I'm using awk to change everything after the [ipv4] settings to either
method=manual
addresses1=100.0.0.1;24;100.0.0.1;
Or
method=auto
Not sure if having done this whether I still need to use ifconfig to set the values for manual ... or whether it will just happen? Guess I'll find out in a few minutes. (Unless either of you lets me know).
With regard to comment about wpa_supplicant - as I don't know what this means (too thick!) I believe I must be using NetworkManager. Should I use wpa_suplicant? Or does it not matter?
Many Thanks again
John
Posted after 1 hour 30 minutes 32 seconds:
Still fighting a losing battle ...
If one edits the file Wired connection 1 directly with vim, the changes are almost immediately reflected (using command ifconfig eth0).
However, if the file is updated using an editor such as Kate or updated using 'cp' command ... although the file is updated, the address does not change.
Any suggestions please?
I had got to the same conclusion as fanthom that I could probably 'play' with the /etc/NetworkManager/system-connections folder contents
... at least that's what I have been trying to script.
I'm very pleased to hear that this should work.
In fact I'm using awk to change everything after the [ipv4] settings to either
method=manual
addresses1=100.0.0.1;24;100.0.0.1;
Or
method=auto
Not sure if having done this whether I still need to use ifconfig to set the values for manual ... or whether it will just happen? Guess I'll find out in a few minutes. (Unless either of you lets me know).
With regard to comment about wpa_supplicant - as I don't know what this means (too thick!) I believe I must be using NetworkManager. Should I use wpa_suplicant? Or does it not matter?
Many Thanks again
John
Posted after 1 hour 30 minutes 32 seconds:
Still fighting a losing battle ...
If one edits the file Wired connection 1 directly with vim, the changes are almost immediately reflected (using command ifconfig eth0).
However, if the file is updated using an editor such as Kate or updated using 'cp' command ... although the file is updated, the address does not change.
Any suggestions please?
- brokenman
- Site Admin
- Posts: 6104
- Joined: 27 Dec 2010, 03:50
- Distribution: Porteus v4 all desktops
- Location: Brazil
- Contact:
Re: DHCPCD - re-allocate IP
Probably the easiest thing (so as not to over complicate things with coding) is to use the built in profile manager in networkmanager.
Here is a video of how to do it. Remember to save your current session (Porteus settings centre) if you are booting in always fresh mode (or make a module of your networkmanager profile folder).
http://youtu.be/BJly2j-KDVc
Creating one profile for DHCP and another for static ip address in networkmanager.
Here is a video of how to do it. Remember to save your current session (Porteus settings centre) if you are booting in always fresh mode (or make a module of your networkmanager profile folder).
http://youtu.be/BJly2j-KDVc
Creating one profile for DHCP and another for static ip address in networkmanager.
How do i become super user?
Wear your underpants on the outside and put on a cape.
Wear your underpants on the outside and put on a cape.
-
- White ninja
- Posts: 18
- Joined: 10 Jul 2012, 07:21
- Location: UK
Re: DHCPCD - re-allocate IP
Many Thanks Brokenman for producing the video.
I can see that this is a tidy way of doing it.
Regards
John
I can see that this is a tidy way of doing it.
Regards
John