View previous topic :: View next topic |
Author |
Message |
ENzero n00b
Joined: 31 Dec 2018 Posts: 2
|
Posted: Mon Dec 31, 2018 1:02 pm Post subject: Setting static IP address to UDHCP client |
|
|
I am using udhcp client for an embedded device. I am trying to add a feature to set a static IP, Netmask, DNS, and gateway address.
I am trying to set it through the "-r" argument (request):
Code: | /sbin/udhcpc -A 3 -f -s /tmp/udhcpc_wlan0_sh -i wlan0 -r 172.16.0.2 |
It does not seem to work. I try to connect my device to an access point and it still used the dhcp deamon provide address.
I was wondering if there are any additional things that I need to do to enable static address. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54096 Location: 56N 3W
|
Posted: Mon Dec 31, 2018 1:54 pm Post subject: |
|
|
ENzero,
Welcome to Gentoo.
-r 172.16.0.2 only requests an address. The DHCP server is not compelled to grant it.
Fix the MAC address in your embedded device, if it isn't already.
Then tell your DHCP server to fix the IP address that is assigned to that MAC address.
You can also configure /etc/conf.d/net to assign a static address.
If you do that, be sure that it is outside the range that your DHCP server can assign. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
bunder Bodhisattva
Joined: 10 Apr 2004 Posts: 5934
|
Posted: Mon Dec 31, 2018 1:54 pm Post subject: |
|
|
in /etc/conf.d/net you can set some of these, but i don't remember where you set the wifi password off hand. (edit: unless your intention is to run hostapd, it goes in there)
Code: | modules_wlan0="!iwconfig !wpa_supplicant" #you probably need to adjust this one
config_wlan0="192.168.2.1 broadcast 192.168.2.255 netmask 255.255.255.0"
channel_wlan0="44"
essid_wlan0="mywifinetwork"
|
_________________
Neddyseagoon wrote: | The problem with leaving is that you can only do it once and it reduces your influence. |
banned from #gentoo since sept 2017 |
|
Back to top |
|
|
ENzero n00b
Joined: 31 Dec 2018 Posts: 2
|
Posted: Tue Jan 01, 2019 10:22 am Post subject: |
|
|
Thanks @NeddySeagoon and @bunder for responding!
I see ... so I don't really tweak anything in for udhcpc.
Quote: | You can also configure /etc/conf.d/net to assign a static address.
If you do that, be sure that it is outside the range that your DHCP server can assign. |
I using just random access points like phones/routers. I am aiming to be able to set static ip inside or outside the dhcp server range if it's possible.
I could not find /etc/conf.d/net since I am working on a horrible proprietary stuff(structure is a bit differnt). Is there a way through terminal to set static address? |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54096 Location: 56N 3W
|
Posted: Tue Jan 01, 2019 4:56 pm Post subject: |
|
|
ENzero,
/etc/conf.d/net does not exist until you create it.
When its missing, dhcpcd or whatever you have installed does its dynamic thing.
I have in /etc/conf.d/net
Code: | config_eth0="192.168.100.20/24 brd 192.168.100.255"
# VM router
routes_eth0="default via 192.168.100.253" |
I need a static IP address to be able to fix things when when my dhcp breaks.
However my dhcp server will only assign 192.168.100.220 to 192.168.100.240 so my static 192.168.100.20 will not cause IP address collisions.
-- edit --
ifconfig <interface> <IP> sets a static IP.
You will also need a default route if you want to connect beyond your local subnet
route add default gw <IP_of_Router> _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
|