Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Setting static IP address to UDHCP client
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ENzero
n00b
n00b


Joined: 31 Dec 2018
Posts: 2

PostPosted: Mon Dec 31, 2018 1:02 pm    Post subject: Setting static IP address to UDHCP client Reply with quote

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
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 42596
Location: 56N 3W

PostPosted: Mon Dec 31, 2018 1:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5803

PostPosted: Mon Dec 31, 2018 1:54 pm    Post subject: Reply with quote

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"

_________________
overlay | patches
Neddyseagoon wrote:
The problem with leaving is that you can only do it once and it reduces your influence.
Back to top
View user's profile Send private message
ENzero
n00b
n00b


Joined: 31 Dec 2018
Posts: 2

PostPosted: Tue Jan 01, 2019 10:22 am    Post subject: Reply with quote

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
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 42596
Location: 56N 3W

PostPosted: Tue Jan 01, 2019 4:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 6972
Location: Saint Amant, Acadiana

PostPosted: Tue Jan 01, 2019 5:00 pm    Post subject: Reply with quote

Quote:
I am working on a horrible proprietary stuff(structure is a bit differnt).

Is it somehow Gentoo based?
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Tue Jan 01, 2019 8:31 pm    Post subject: Reply with quote

ENzero wrote:
Is there a way through terminal to set static address?


ip addr add 192.168.0.1/24 dev eth0
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum