Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Ignore hostname from DHCP server.
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
Jhedron
n00b
n00b


Joined: 07 Jun 2005
Posts: 45
Location: Michigan, USA

PostPosted: Tue Aug 05, 2014 3:17 am    Post subject: [SOLVED] Ignore hostname from DHCP server. Reply with quote

Long story short: my shiny, new wireless router has some issues so I've had to fall back on the routing capabilities of the Zyxel P-660H-D1 provided by my ISP. This is the first time I've had to use the routing capabilities of the device. Unlike every other home router I've had, the Zyxel is trying to assign hostnames to all of my devices via DHCP. It's getting annoying because hostnames like "dhcppc3" aren't all that useful to me. Since I apparently don't have access to the settings which control these hostnames, is there a way to tell Network Manager to ignore the DHCP hostname and stick with the hostname I've defined for the machine?

Relevant lines from my log:
Code:
Aug 04 22:31:33 alexandra NetworkManager[307]: <info> (lan0): DHCPv4 state changed preinit -> reboot
Aug 04 22:31:33 alexandra NetworkManager[307]: <info>   address x.x.x.x
Aug 04 22:31:33 alexandra NetworkManager[307]: <info>   prefix 24 (255.255.255.0)
Aug 04 22:31:33 alexandra NetworkManager[307]: <info>   gateway x.x.x.x
Aug 04 22:31:33 alexandra NetworkManager[307]: <info>   hostname 'dhcppc0'
Aug 04 22:31:33 alexandra NetworkManager[307]: <info>   nameserver 'x.x.x.x'
Aug 04 22:31:33 alexandra NetworkManager[307]: <info>   nameserver 'x.x.x.x'
Aug 04 22:31:33 alexandra NetworkManager[307]: <info>   domain name ''
Aug 04 22:31:33 alexandra NetworkManager[307]: nm_ip4_config_add_domain: assertion 'strlen (domain) > 0' failed
Aug 04 22:31:33 alexandra NetworkManager[307]: <info>   domain name ''
Aug 04 22:31:33 alexandra NetworkManager[307]: nm_ip4_config_add_domain: assertion 'strlen (domain) > 0' failed
Aug 04 22:31:33 alexandra NetworkManager[307]: <info> Activation (lan0) Stage 5 of 5 (IPv4 Configure Commit) scheduled...
Aug 04 22:31:33 alexandra NetworkManager[307]: <info> Activation (lan0) Stage 5 of 5 (IPv4 Commit) started...
Aug 04 22:31:34 alexandra NetworkManager[307]: <info> (lan0): device state change: ip-config -> secondaries (reason 'none') [70 90 0]
Aug 04 22:31:34 alexandra NetworkManager[307]: <info> Activation (lan0) Stage 5 of 5 (IPv4 Commit) complete.
Aug 04 22:31:34 alexandra NetworkManager[307]: <info> (lan0): device state change: secondaries -> activated (reason 'none') [90 100 0]
Aug 04 22:31:34 alexandra NetworkManager[307]: <info> NetworkManager state is now CONNECTED_GLOBAL
Aug 04 22:31:34 alexandra NetworkManager[307]: <info> Policy set 'Wired connection 1' (lan0) as default for IPv4 routing and DNS.
Aug 04 22:31:34 alexandra NetworkManager[307]: <info> Setting system hostname to 'dhcppc0' (from DHCPv4)


And here's the hostname information for the same machine:
Code:
$ hostnamectl
   Static hostname: alexandra
Transient hostname: dhcppc0
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: xxxxxxxxxx
           Boot ID: xxxxxxxxxx
  Operating System: Gentoo/Linux
            Kernel: Linux 3.15.8-gentoo
      Architecture: x86-64


Last edited by Jhedron on Wed Aug 06, 2014 3:10 am; edited 1 time in total
Back to top
View user's profile Send private message
wraeth
Developer
Developer


Joined: 08 May 2007
Posts: 72
Location: Australia

PostPosted: Tue Aug 05, 2014 2:01 pm    Post subject: Reply with quote

If you use dhcpcd as your DHCP client backend, the you should be able to set something up in /etc/dhcpcd.conf.
Code:
#
# Options for interface enp2s10 only
#

# This interface only below this point
interface enp2s10                     
# Send this hostname to the DHCP server
hostname cerberus2

See man dhcpcd.conf for more configuration options.

You should also double-check that your local hostname is configured correctly in the appropriate locations - /etc/conf.d/hostname for OpenRC and by using the command hostnamectl for systemd.
Back to top
View user's profile Send private message
Jhedron
n00b
n00b


Joined: 07 Jun 2005
Posts: 45
Location: Michigan, USA

PostPosted: Wed Aug 06, 2014 3:10 am    Post subject: Reply with quote

wraeth wrote:
If you use dhcpcd as your DHCP client backend, the you should be able to set something up in /etc/dhcpcd.conf.
Code:
#
# Options for interface enp2s10 only
#

# This interface only below this point
interface enp2s10                     
# Send this hostname to the DHCP server
hostname cerberus2

See man dhcpcd.conf for more configuration options.

Thanks for pointing me to dhcpcd.conf. I forgot that NetworkManager doesn't handle the DHCP stuff itself. I first tried setting the hostname explicitly, as in your example:
Code:
# Should send the current system hostname, but didn't work...
#hostname
# ...so set the hostname explicitly.
hostname alexandra

When that didn't work, I noticed the following line:
Code:
option domain_name_servers, domain_name, domain_search, host_name

After reading what the man page had to say about it, I tried removing host_name. That seemed to do the trick.
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Wed Aug 06, 2014 3:31 am    Post subject: Reply with quote

OR, if you don't want a DHCP derivated hostname, set one! local setting > DHCP always :)
_________________
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
Jhedron
n00b
n00b


Joined: 07 Jun 2005
Posts: 45
Location: Michigan, USA

PostPosted: Fri Aug 08, 2014 9:49 pm    Post subject: Reply with quote

UberLord wrote:
OR, if you don't want a DHCP derivated hostname, set one! local setting > DHCP always :)

I thought I did have a hostname set. I use systemd, so I ran the following when I setup my machine:
Code:
# hostnamectl set-hostname alexandra

And I have this:
Code:
$ cat /etc/hostname
alexandra
$ hostnamectl
   Static hostname: alexandra
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: xxxxxxxxxx
           Boot ID: xxxxxxxxxx
  Operating System: Gentoo/Linux
            Kernel: Linux 3.15.8-gentoo
      Architecture: x86-64

Is there something else I need to do to make sure I have a hostname set?
Back to top
View user's profile Send private message
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2253
Location: $TERM

PostPosted: Sun Aug 02, 2015 6:54 am    Post subject: Reply with quote

Dhcpcd can't ignore the hostname sent by the server. I would call this a vulnerability. Time to dump dhcpcd.
_________________
My blog
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Sun Aug 02, 2015 2:05 pm    Post subject: Reply with quote

dE_logics wrote:
Dhcpcd can't ignore the hostname sent by the server. I would call this a vulnerability. Time to dump dhcpcd.


Time to dump your ignorance!

1) Don't request it in dhcpcd.conf
2) If the server send it anyway, tell dhcpcd not to use it.
Code:

nooption hostname

3) 30-hostname hook script will not use it UNLESS a hostname has not already been set OR the force hostname option is set, which it isn't by default.
_________________
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
dE_logics
Advocate
Advocate


Joined: 02 Jan 2009
Posts: 2253
Location: $TERM

PostPosted: Sun Aug 02, 2015 2:23 pm    Post subject: Reply with quote

I'll get it back on board next time.

Thanks for that.
_________________
My blog
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