Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
4
votes
1
answers
9354
views
Cannot get IP address from WiFi access point (hostapd) with DHCP (dnsmasq) bridged with two ethernet adapters (bridge-utils)
**My Android phone is trying to get DHCP address through WiFi connection, but fails.** Obviously, I might have messed up something in my settings because I couldn't find a complete guide which would let me do everything in one go, thus I had to combine multiple guides, but I still feel a bit new to...
**My Android phone is trying to get DHCP address through WiFi connection, but fails.**
Obviously, I might have messed up something in my settings because I couldn't find a complete guide which would let me do everything in one go, thus I had to combine multiple guides, but I still feel a bit new to network configuration on Linux.
What I want to achieve:
**- create a WiFi access point and DHCP server where all devices receive IP adresses in the same network. Internet access not required, so no routing needed - just a local network where my server acts as a switch (bridge) providing IP adresses for all devices connected to it through WiFi or Ethernet.**
Here's what I have:
- a Linux machine (actually, Raspberry Pi with Raspbian) with Ralink RT5370 WiFi dongle (which claims to support Access Point) and two Ethernet ports - one is RPi's built-in port and the other is Trendnet TU2-ET100 (chip AX88772)
- I have installed bridge-utils and dnsmasq and everything works fine with Ethernet connections - all devices connected to RPi Ethernet ports receive their IP addresses from RPi through dnsmasq
- I have installed hostapd and configured it to be open AP, for starters. I tried to use WPA, but on my Android phone that also failed with "Authentication failure", so I disabled auth. And now my Android device gets stuck while acquiring IP address and then fails.
Here are my config files:
/etc/default/hostapd:
interface=wlan0
hw_mode=g
bridge=br0
channel=1
ssid=FakeTestServer_AP
auth_algs=1
wmm_enabled=0
/etc/default/hostapd:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
/etc/network/interfaces:
auto lo
iface lo inet loopback
auto br0
iface eth0 inet manual
iface eth1 inet manual
iface br0 inet static
bridge_ports eth0 eth1 wlan0
bridge_stp off
bridge_fd 0
bridge_waitport 0
bridge_maxwait 0
address 10.0.0.1
netmask 255.255.255.0
/etc/dnsmasq.conf:
interface=br0
dhcp-range=10.0.0.2,10.0.0.254,255.255.255.0,12h
Here is what
ifconfig
shows:
br0 Link encap:Ethernet HWaddr 00:14:d1:da:c7:dc
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::214:d1ff:feda:c7dc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1343 errors:0 dropped:0 overruns:0 frame:0
TX packets:212 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:83674 (81.7 KiB) TX bytes:16750 (16.3 KiB)
eth0 Link encap:Ethernet HWaddr b8:27:eb:74:1f:8c
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:5824 errors:0 dropped:0 overruns:0 frame:0
TX packets:2800 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1448587 (1.3 MiB) TX bytes:1057796 (1.0 MiB)
eth1 Link encap:Ethernet HWaddr 00:14:d1:da:c7:dc
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5353 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1145578 (1.0 MiB) TX bytes:414153 (404.4 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:52 errors:0 dropped:0 overruns:0 frame:0
TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3744 (3.6 KiB) TX bytes:3744 (3.6 KiB)
mon.wlan0 Link encap:UNSPEC HWaddr 00-C1-40-95-0D-43-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7417 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2107086 (2.0 MiB) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 00:c1:40:95:0d:43
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:182 errors:0 dropped:0 overruns:0 frame:0
TX packets:122 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31498 (30.7 KiB) TX bytes:21682 (21.1 KiB)
To make it clear, I repeat - the bridge and both Ethernet connections work fine, and there are no any errors when I run:
sudo service hostapd restart
sudo service dnsmasq restart
sudo service networking restart
At the very beginning bridge-utils failed with a message
can't add wlan0 to bridge br0: Operation not supported
but after I added bridge=br0
to hostapd settings, bridge-utils did not complain anymore, so I guess, wlan0 got added to the bridge but I'm not sure what's going on there.
**How do I get my WiFi working in Access Point mode and be part of the same bridge as both eth0 and eth1 are?**
JustAMartin
(203 rep)
Apr 16, 2015, 08:49 AM
• Last activity: Aug 3, 2025, 04:04 PM
1
votes
2
answers
280
views
systemd-networkd 'relaytarget' not working (dhcp relay) in Debian stable 12 bookworm
my first question here. I'm currently using the 'dhcp-helper' program to do dhcp relay, works fine, but I want to switch to using the systemd-networkd 'RelayTarget' function in the *.network file. I've tried every option I can think of, but can't seem to get it working. * Running current Debian stab...
my first question here.
I'm currently using the 'dhcp-helper' program to do dhcp relay, works fine, but I want to switch to using the systemd-networkd 'RelayTarget' function in the *.network file. I've tried every option I can think of, but can't seem to get it working.
* Running current Debian stable "bookworm 12" 6.1.0-13-amd64
* Debian stable runs systemd 252 (252.17-1~deb12u1)
I've tried every option I can think of, no luck yet.
/etc/systemd/network/02-port2-lan0-static.network:
# /etc/systemd/network/02-port2-lan0-static.network
# configures lan0 with static ip address
#
[Match]
Name=lan0
[Network]
Address=172.16.1.1/24
# do not set gateway or dns, will inherit from system
[DHCPServer]
ServerAddress=172.16.11.2/24
RelayTarget=172.16.11.2
BindToInterface=no
Anyone have this working in Debian stable? I realize Debian stable does not run the latest systemd version. This is a production router, so upgrading to testing is not an option.
Thanks
drokmed
(11 rep)
Nov 4, 2023, 08:23 PM
• Last activity: Jul 30, 2025, 10:03 AM
0
votes
1
answers
4204
views
Setting up a fixed IP wifi hotspot (with no internet) with DHCP and DNS using dnsmasq
I'm having trouble setting up my computer (running Ubuntu 18.04) as a hotspot with a manually fixed IP. I want devices to be able to connect to it via WiFi, and for them to be able to access my website hosted on the computer on port 80. So I wanted to set the fixed IP of my computer as 192.168.10.1,...
I'm having trouble setting up my computer (running Ubuntu 18.04) as a hotspot with a manually fixed IP. I want devices to be able to connect to it via WiFi, and for them to be able to access my website hosted on the computer on port 80.
So I wanted to set the fixed IP of my computer as 192.168.10.1, so I set up the hotspot as such:
INTERFACE=wlan0 # My wifi card interface
CONNECTION_NAME=testhotspot
MY_IP="192.168.10.1"
sudo nmcli con add type wifi ifname $INTERFACE con-name $CONNECTION_NAME autoconnect yes ssid $CONNECTION_NAME
sudo nmcli con modify $CONNECTION_NAME 802-11-wireless.mode ap ipv4.method manual ipv4.addresses $MY_IP/24 ipv4.gateway $MY_IP
sudo nmcli con modify $CONNECTION_NAME wifi-sec.key-mgmt wpa-psk
sudo nmcli con modify $CONNECTION_NAME wifi-sec.psk "somepassword"
# do I need to set ipv4.dns?
I then set up dnsmasq (in /etc/dnsmasq
) as:
address=/#/127.0.0.1
interface=wlan0
except-interface=lo
listen-address=::1,127.0.0.1,192.168.10.1
# DHCP setup
dhcp-range=192.168.10.100,192.168.10.200,12h # lease out 192.168.10.100-200
dhcp-option=option:router,192.168.10.1
dhcp-option=option:dns-server,192.168.10.1
dhcp-option=option:netmask,255.255.255.0
dhcp-leasefile=/var/lib/misc/dnsmasq.leases
dhcp-authoritative
Startup dnsmasq and the hotspot:
sudo nmcli con up testhotspot
sudo systemctl restart dnsmasq.service
With this setup, I found that connecting to the wifi hotspot on another computer running Ubuntu (let's call this computer B), I could successfully ping 192.168.1.10 and access my website on 192.168.10.1:80.
However, I had issues trying to connect to it using an Android phone, with the connection continuously dropping. I had to change my Android wifi settings to "Static" instead of "DHCP", and specify the DNS to 192.168.10.1 for me to successfully ping 192.168.10.1. Thus, I guessed that I hadn't "announced" to clients properly about my DNS/DHCP server? I tried changing my hotspot settings as nmcli con modify testhotspot ipv4.dns 192.168.10.1
. However, this did not solve the issue on my Android device (It stopped dropping the wifi connection, but I still could not ping 192.168.10.1?).
I also noticed that on computer B, while connected to both the wifi of my hotspot server, and an internet-providing router, some public websites (such as this askubuntu site) could not be reached until I turned off the wifi connection to the hotspot server. What did I do wrong in the setup above?
kekpirat
(101 rep)
Sep 14, 2022, 02:12 AM
• Last activity: Jul 19, 2025, 01:03 AM
0
votes
0
answers
12
views
dnsmasq '--read-ethers' and '--address' interaction
I run dnsmasq on a server (specifically OpenWrt) to act as both DHCP and DNS. OpenWrt DHCP configuration `/etc/config/dhcp`: option readethers '1' list address '/my-phone.lan/172.28.79.133' Which is equivalent to running: dnsmasq --read-ethers --address='/my-phone.lan/172.28.79.133' nslookup works a...
I run dnsmasq on a server (specifically OpenWrt) to act as both DHCP and DNS.
OpenWrt DHCP configuration
/etc/config/dhcp
:
option readethers '1'
list address '/my-phone.lan/172.28.79.133'
Which is equivalent to running:
dnsmasq --read-ethers --address='/my-phone.lan/172.28.79.133'
nslookup works and resolves the name to IP correctly. I set this in /etc/ethers
:
00:c7:11:b4:19:1a my-phone.lan
From dnsmasq manpage:
> **-Z, --read-ethers**
> Read /etc/ethers for information about hosts for the DHCP server. The format of /etc/ethers is a hardware address, followed
> by either a hostname or dotted-quad IP address. When read by dnsmasq
> these lines have exactly the same effect as --dhcp-host options
> containing the same information. /etc/ethers is re-read when dnsmasq
> receives SIGHUP. IPv6 addresses are NOT read from /etc/ethers.
When my phone connects to the network, it does not receive the DHCP lease 172.28.79.133.
But if I don't use dnsmasq --address
and instead set it in /etc/hosts
:
172.28.79.133 my-phone.lan
It works and my phone does receive the correct DHCP lease. Why is that?
Livy
(455 rep)
Jul 10, 2025, 08:56 AM
• Last activity: Jul 10, 2025, 09:03 AM
1
votes
2
answers
3674
views
When no dhcp server answer, how can I force dhclient to use the static lease from dhclient.conf instead of a previous dhcp lease?
I have a piece of equipment I would like to default to a specific IP address when no dhcp servers are available. I have set the following static lease in /etc/dhcp/dhclient.conf: timeout 30; lease { interface "eth0"; fixed-address 192.168.1.254; option subnet-mask 255.255.255.0; option routers 127.0...
I have a piece of equipment I would like to default to a specific IP address when no dhcp servers are available.
I have set the following static lease in /etc/dhcp/dhclient.conf:
timeout 30;
lease {
interface "eth0";
fixed-address 192.168.1.254;
option subnet-mask 255.255.255.0;
option routers 127.0.0.1;
expire never;
}
It works, but eth0 will only get this IP when dhclient.eth0.leases and dhclient.leases in /var/lib/dhcp/ are empty.
Unless you guys have a good reason to advise against it, I would prefer if the static lease from dhclient.conf was assigned when a dhcp server doesn't reply instead of using old leases. It would make the troubleshooting process easier and allow some way to reach the equipment which is only accessible via ssh and has no display to print out the current ip.
I read through the dhclient manual and a lot of google search results but couldn't find a built in way or any suggestions on how to do this.
**Solutions I thought of:**
1-Empty dhclient.leases and set permissions so it can't be modified
2-Link dhclient.leases to /dev/null and set permissions so it can't be modified
3-Same as #1 but instead of setting up the static lease in dhclient.conf, manually add it to dhclient.leases before setting permissions.
2-Link dhclient.leases to /dev/null and set permissions so it can't be modified
3-Same as #1 but instead of setting up the static lease in dhclient.conf, manually add it to dhclient.leases before setting permissions.
TCZ8
(1109 rep)
Dec 15, 2015, 04:48 PM
• Last activity: Jul 8, 2025, 10:03 PM
1
votes
1
answers
62
views
Client PC (with DHCP assigned IP) cannnot get the Internet
I have one computer, Server, with two Ethernet ports, enp2s0 and enp3s0. What I want to do is that I want this computer to connect to the internet via company network (10.11.1.0/24) and also be a DHCP server, assigning IPs of 192.168.6.0/24 to other computers, which connects with enp3s0. Now, the ne...
I have one computer, Server, with two Ethernet ports, enp2s0 and enp3s0.
What I want to do is that I want this computer to connect to the internet via company network (10.11.1.0/24) and also be a DHCP server, assigning IPs of 192.168.6.0/24 to other computers, which connects with enp3s0.
Now, the network is:
**On Server (with isc-dhcp-server running):**
- enp2s0 connects to company network and gets static ip 10.11.1.225/24
- enp3s0 I manually signed an IP, 192.168.6.1 to it.
**On Client PC (connects to Server's enp3s0)**
- enp2s0f3 gets IP 192.168.6.51/24
I can see isc-dhcp-server.service is working on Sever as Client PC gets IP without any problems. On Server, it can gets on the internet.
However, ***Client PC can NOT get internet but can ping 192.168.6.1.***
I'm not sure what else I need to do or something I did wrong.
I google it and I think it has something to do with routing but have no clue what to do. I'm pretty green on this networking thing, so if possible, please help with detailed info. Thank you. More information below:
On Server:
[root@Server~]# ip -4 -br a
lo UNKNOWN 127.0.0.1/8
enp2s0 UP 10.11.1.225/24
enp3s0 UP 192.168.6.1/24
[root@Server~]# sysctl -p
net.ipv4.ip_forward = 1
[root@Server~]# ip r
default via 10.11.1.254 dev enp2s0 proto static
10.11.1.0/24 dev enp2s0 proto kernel scope link src 10.11.1.225
192.168.6.0/24 dev enp3s0 proto kernel scope link src 192.168.6.1
[root@Server~]# cat /etc/dhcp/dhcpd.conf
# option definitions common to all supported networks...
#option domain-name "example.org";
option domain-name-servers 8.8.8.8, 8.8.4.4;
default-lease-time 600;
max-lease-time 7200;
authoritative;
subnet 192.168.6.0 netmask 255.255.255.0 {
range 192.168.6.50 192.168.6.55;
option routers 192.168.6.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.6.255;
}
[root@Server~]# cat /etc/default/isc-dhcp-server
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="enp3s0"
INTERFACESv6=""
On the Client PC:
[root@ClientPC~]# ip -br a
lo UNKNOWN 127.0.0.1/8 ::1/128
enp2s0f3 UP 192.168.6.51/24 metric 1024 fe80::210:f3ff:fea9:6276/64
[root@ClientPC~]# ip r
default via 192.168.6.1 dev enp2s0f3 proto dhcp src 192.168.6.51 metric 1024
8.8.4.4 via 192.168.6.1 dev enp2s0f3 proto dhcp src 192.168.6.51 metric 1024
8.8.8.8 via 192.168.6.1 dev enp2s0f3 proto dhcp src 192.168.6.51 metric 1024
192.168.6.0/24 dev enp2s0f3 proto kernel scope link src 192.168.6.51 metric 1024
192.168.6.1 dev enp2s0f3 proto dhcp scope link src 192.168.6.51 metric 1024
XavierWood
(87 rep)
Jul 4, 2025, 03:34 AM
• Last activity: Jul 7, 2025, 05:47 AM
2
votes
1
answers
2111
views
What is the default behaviour of IPv4LL on Linuxsystems?
I'm looking for a good source and confirmation about **Dynamic Configuration of IPv4 Link-Local Addresses.** The rfc [Dynamic Configuration of IPv4 Link-Local Addresses][1] didn't really help answer my question (or I'm looking over it). *So let's review, to make sure I am right:* When a device conne...
I'm looking for a good source and confirmation about **Dynamic Configuration of IPv4 Link-Local Addresses.**
The rfc Dynamic Configuration of IPv4 Link-Local Addresses didn't really help answer my question (or I'm looking over it).
*So let's review, to make sure I am right:*
When a device connects to the internet, and it doesn't get an IP from either DHCP or static. Then the device receives an IP in the 169.254/16 range. This process is called *APIPA* (=Automatic Private IP Addressing) on Microsoft Operating systems and is the default course of actions. A Linux variant is seemingly zeroconf/Avahi.
*My Question:*
Is the receiving of the IP in the range a default behaviour on any system (so on any Linux system). Or is/should it be configured by the OS. As far as I know when booting on Ubuntu and not doing "anything" will result in not getting an IP whatsoever (so no 169.254.x.y/16).
In other words when we speak of not getting a IP from DHCP (and not statically setting one). Will/should I receive a 169.245/16 IP on every system or is this Microsoft-only stuff?
EDIT: also what does OSX do?
Ciberth
(151 rep)
Jun 17, 2016, 09:52 PM
• Last activity: Jun 26, 2025, 09:04 PM
2
votes
2
answers
2515
views
Specify unique DHCP hostnames for multiple network interfaces
I am running Ubuntu Server 20.04 in a VM under ESXi on my home server. I would like the VM to have two unique IP addresses, with the goal of being able to run two separate instances of PiHole in docker containers. I have configured two network adapters on the VM, and then configured /etc/netplan/00-...
I am running Ubuntu Server 20.04 in a VM under ESXi on my home server. I would like the VM to have two unique IP addresses, with the goal of being able to run two separate instances of PiHole in docker containers.
I have configured two network adapters on the VM, and then configured /etc/netplan/00-installer-config.yaml as:
network:
ethernets:
ens160:
dhcp4: true
ens192:
dhcp4: true
version: 2
After running netplan apply
, I have two interfaces, each with their own IP via DHCP.
# ifconfig
ens160: flags=4163 mtu 1500
inet 10.0.0.212 netmask 255.255.255.0 broadcast 10.0.0.255
...
ens192: flags=4163 mtu 1500
inet 10.0.0.213 netmask 255.255.255.0 broadcast 10.0.0.255
...
I have then edited /etc/dhcp/dhclient.conf
by commenting out the default 'send host-name' option and replacing it with two interface-specific options:
#send host-name = gethostname();
interface "ens160" {
send host-name = "something-else-1";
}
interface "ens192" {
send host-name = "something-else-2";
}
It's this step that does not seem to work. The DHCP server (Unifi) still reports the hostname as 'experimental'. In fact, I tried just changing the existing gethostname()
line to just have some other hostname, and even that does not seem to work.
I tried changing /etc/hostname
to use something different, and that did work. So it seems like the options in /etc/dhcp/dhclient.conf
are just being ignored for some reason.
Can anyone tell me what I'm doing wrong? Thanks!
antsyawn
(121 rep)
Jun 27, 2020, 02:53 AM
• Last activity: Jun 9, 2025, 07:03 PM
2
votes
1
answers
8766
views
udhcpc: no lease, failing WHEN booting on embedded linux created by Buildroot
The responsiveness of the Linux service `udhcpc` (native DHCP relative to `/etc/init.d/S40network` service which invokes `ip up` and `udhcpc`) differs before and after logging at the prompt. When invoked via `/etc/init.d/rcS` (boot sequence), `udhcpc` does not assign an IP address: udhcpc: no lease,...
The responsiveness of the Linux service
udhcpc
(native DHCP relative to /etc/init.d/S40network
service which invokes ip up
and udhcpc
) differs before and after logging at the prompt.
When invoked via /etc/init.d/rcS
(boot sequence), udhcpc
does not assign an IP address:
udhcpc: no lease, failing
However, once logged in, with the root account, the S40network restart
provides an IP address very quickly via udhcpc
.
The /etc/inittab
is normal and basic:
# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen
#
# Note: BusyBox init doesn't support runlevels. The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: :::
#
# id == tty to run on, or empty for /dev/console
# runlevels == ignored
# action == one of sysinit, respawn, askfirst, wait, and once
# process == program to run
# Startup the system
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -o remount,rw /
::sysinit:/bin/mkdir -p /dev/pts
::sysinit:/bin/mkdir -p /dev/shm
::sysinit:/bin/mount -a
::sysinit:/bin/hostname -F /etc/hostname
# now run any rc scripts
::sysinit:/etc/init.d/rcS
# Put a getty on the serial port
ttyPS0::respawn:/sbin/getty -L ttyPS0 0 vt100 # GENERIC_SERIAL
# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
How can we explain this ?
stefff
(21 rep)
Apr 23, 2018, 06:45 PM
• Last activity: Jun 5, 2025, 03:04 PM
0
votes
1
answers
511
views
Ubuntu server not responding after few days
I would like know if anyone else has had this problem. I have my own device as a server with Ubuntu Server operating system in the server room. After some time the server always stops responding to ping while the server is still running. I have to restart it and then everything runs fine again for s...
I would like know if anyone else has had this problem. I have my own device as a server with Ubuntu Server operating system in the server room. After some time the server always stops responding to ping while the server is still running. I have to restart it and then everything runs fine again for some time.
I have tried this even on a clean Ubuntu server without any other services. I have gone through the logs but found no problem in them. I would still like to try setting the ip to static to avoid the problem from DHCP.
**Update:**
Today, I was at the server and found the PC running. The network card is communicating, but there’s no signal after connecting the VGA cable.
The disk activity light wasn’t even on, though the fans were spinning.
The computer can only be turned off by a hard shutdown.
I think the issue might be hardware-related, but where exactly?
Mydo
(1 rep)
May 16, 2024, 07:04 AM
• Last activity: Jun 1, 2025, 09:03 AM
3
votes
2
answers
5067
views
Why are routes set in /etc/network/interfaces not added when the interface comes up?
Here is my interfaces file: auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp auto eth0:0 iface eth0:0 inet static address 10.20.8.231 netmask 255.255.255.0 gateway 10.20.8.1 up /sbin/route add 1.2.3.4 gw 10.20.8.1 down /sbin/route del 1.2.3.4 gw 10.20.8.1 From the multiple examples I ha...
Here is my interfaces file:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth0:0
iface eth0:0 inet static
address 10.20.8.231
netmask 255.255.255.0
gateway 10.20.8.1
up /sbin/route add 1.2.3.4 gw 10.20.8.1
down /sbin/route del 1.2.3.4 gw 10.20.8.1
From the multiple examples I have found online this should add routes when eth0:0 comes up but for some reason I can't get it to work.
When I try to bring up the interface with
**Thank you for your assistance.**
ifup eth0:0
I get:
RTNETLINK answers: File exists
Failed to bring up eth0:0.
Then, ifconfig
shows eth0:0 is up but route -n
does not show the new route. In fact it shows the exact same routes I had before. Nothing changed.
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.20.8.1 0.0.0.0 UG 0 0 0 eth0
10.20.8.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
This config is to be used on remote systems that can only be accessed via SSH. The whole idea is to keep eth0 set to dhcp as a backup when the site's network is changed (happened twice already) rendering the static ip unaccessible. The problem with this is that SSH (used by built in processes) uses the default route via eth0 and that doesn't work as the firewall (not managed by us) has been set to allow ssh only for the static IP on eth0:0.
Note: In the example above 1.2.3.4 represents our ssh server and I am trying to route traffic via eth0:0 for that single host but after testing I may want to set the default route to use eth0:0 instead, but I also tried that and it failed the same way. I was using this line:
up route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.20.8.1
**Thank you for your assistance.**
TCZ8
(1109 rep)
Dec 21, 2015, 03:58 PM
• Last activity: May 24, 2025, 04:29 PM
28
votes
4
answers
39561
views
how do you set up a linux client to use ntp information provided through dhcp?
there are so many tutorials out there explaining how to setup `dhcpd` server, in relation to providing ntp suggestions to dhcp clients, that I had always thought that `ntp` configuration was carried out automatically. Recently I started seeing clock drifts in my local network, so I assume this was a...
there are so many tutorials out there explaining how to setup
dhcpd
server, in relation to providing ntp suggestions to dhcp clients, that I had always thought that ntp
configuration was carried out automatically. Recently I started seeing clock drifts in my local network, so I assume this was a wrong assumption. So I set out to see how can one minimize the ntp client configuration, provided one has carried out the effort to set up ntp-server
suggestions through dhcpd
.
I have not been able to find much apart from this Ubuntu specific help tutorial https://help.ubuntu.com/community/UbuntuTime . Even here (see paragraph under "Troubleshooting -> Which configuration file is it using?") the information is scarce but it says that if an /etc/ntp.conf.dhcp
file is found it will be used instead. First of all the actual location that the writer meant here is /var/lib/ntp/ntp.conf.dhcp
as observed in /etc/init.d/ntp
, but regardless of that the presence of this file does not guarantee that the ntp will request servers from dhclient
. As a result, I have to explicitly add the server
clause in ntp.conf.dhcp
for my local ntp server. But in that case, why do I even setup ntp settings on the dhcpd
server?
This seems to go against intuition, ie setup ntp settings once (ie on the server) and let dhcpd
server delegate the information to the clients. How can I minimize (if not avoid altogether), client configuration for the ntp. Alternatively, how can I get ntp
information through dhclient
.
Is there a cli solution that fits all linux distros?
I assume every client should have the executables of ntpd
, but I do not know how to proceed from there.
Thank you
EDIT:
ubuntu client verbose output when running manually dhclient
:
sudo dhclient -1 -d -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eth0/20:cf:30:0e:6c:12
Sending on LPF/eth0/20:cf:30:0e:6c:12
Sending on Socket/fallback
DHCPREQUEST of 192.168.112.150 on eth0 to 255.255.255.255 port 67 (xid=0x2e844b8f)
DHCPACK of 192.168.112.150 from 192.168.112.112
reload: Unknown instance:
invoke-rc.d: initscript smbd, action "reload" failed.
RTNETLINK answers: File exists
* Stopping NTP server ntpd
...done.
* Starting NTP server ntpd
...done.
bound to 192.168.112.150 -- renewal in 41963 seconds.
The ntpd service is restarted, yet running ntpq -cpe -cas
afterwards I still do not see my local ntp server in the list of ntp servers.
Of course my dhcpd
server does have option ntp-servers
subnet 192.168.112.0 netmask 255.255.255.0 {
max-lease-time 604800;
default-lease-time 86400;
authoritative;
ignore client-updates;
option ntp-servers 192.168.112.112; #self
... (many other options)
}
nass
(1508 rep)
Dec 4, 2016, 03:09 PM
• Last activity: May 20, 2025, 10:55 AM
0
votes
1
answers
2124
views
How to setup dhcp server and client on linux local virtual network interfaces
For my task i need to dump dhcp client-server exchange in local linux machine. 1. First of all i clone and build dhcp server and client from ISC dhcp sources - https://github.com/isc-projects/dhcp. 2. Create and setup tap interfaces in bridge for my experiments: ``` sudo ip link add test_eth0 type t...
For my task i need to dump dhcp client-server exchange in local linux machine.
1. First of all i clone and build dhcp server and client from ISC dhcp sources - https://github.com/isc-projects/dhcp .
2. Create and setup tap interfaces in bridge for my experiments:
sudo ip link add test_eth0 type tap
sudo ip link add test_eth1 type tap
sudo ip link add test_eth2 type tap
sudo ifconfig test_eth0 up
sudo ifconfig test_eth1 up
sudo ifconfig test_eth2 up
sudo ifconfig test_eth0 10.1.1.7 netmask 255.255.255.0 up
sudo ip link add test_br0 type bridge
sudo ip link set dev test_eht0 master test_br0
sudo ip link set dev test_eht1 master test_br0
sudo ip link set dev test_eht2 master test_br0
sudo ip link set test_br0 up
3. Start dhcpd server
./dhcpd -d -f # start dhcp daemon in foreground mode
with dhcpd.conf:
...
subnet 10.1.1.0 netmask 255.255.255.0 {
range 10.1.1.3 10.1.1.254;
option routers 10.1.1.1;
}
...
4. Start dhclient specifying target interface and dhcp server:
./dhclient -lf ./dhclient.leases test_eth1 -s 10.1.1.0 -v
client output:
...
DHCPDISCOVER on test_eht1 to 10.1.1.0 port 67 interval 3
DHCPDISCOVER on test_eht1 to 10.1.1.0 port 67 interval 6
DHCPDISCOVER on test_eht1 to 10.1.1.0 port 67 interval 11
...
I expected that after starting the client, it will detect a running server, which will give a dynamic address to the test_eth1 interface and i can dump it with dhcpdump, but i'm not so good in networking as in my imagine.
stupidnix
(1 rep)
Jul 15, 2021, 07:23 AM
• Last activity: May 13, 2025, 02:02 AM
0
votes
1
answers
131
views
PXE reading the file name incorrectly
I’m setting up a PXE boot environment using a DHCP server and a Realtek RTL8168 NIC (bulit-in ethernet on my mainboard). I’ve configured DHCP Option 67 to send the boot file name (netboot.xyz.efi), but during the PXE boot process, the client is displaying the file name with a single weird character....
I’m setting up a PXE boot environment using a DHCP server and a Realtek RTL8168 NIC (bulit-in ethernet on my mainboard). I’ve configured DHCP Option 67 to send the boot file name (netboot.xyz.efi), but during the PXE boot process, the client is displaying the file name with a single weird character. This results in boot failure (file not found).
My PXE server is using
Here is my router configuration, it is a Huawei HG8145V5-20 (modified firmware by ISP).
Edit: This looks like a firmware bug. I give up.
tftpd-hpa/noble,now 5.2+20150808-1.4build1 amd64
I've verified that in the tftp root directory, netboot.xyz.efi
existed (downloaded from [netboot.xyz](https://netboot.xyz/downloads))

dhcptest v0.7 - Created by Vladimir Panteleev
https://github.com/CyberShadow/dhcptest
Run with --help for a list of command-line options.
Listening for DHCP replies on port 68.
Sending packet:
op=BOOTREQUEST chaddr=BD:2E:47:6A:89:7C hops=0 xid=8B6211E2 secs=0 flags=8000
ciaddr=0.0.0.0 yiaddr=0.0.0.0 siaddr=0.0.0.0 giaddr=0.0.0.0 sname= file=
1 options:
53 (DHCP Message Type): discover
Received packet from 10.0.1.1:67:
op=BOOTREPLY chaddr=BD:2E:47:6A:89:7C hops=0 xid=8B6211E2 secs=0 flags=8000
ciaddr=0.0.0.0 yiaddr=10.0.1.68 siaddr=0.0.0.0 giaddr=0.0.0.0 sname= file=
8 options:
53 (DHCP Message Type): offer
54 (Server Identifier): 10.0.1.1
51 (IP Address Lease Time): 60 (1 minute)
1 (Subnet Mask): 255.255.255.0
3 (Router Option): 10.0.1.1
6 (Domain Name Server Option): 1.1.1.1, 1.0.0.1
66 (TFTP server name): 10.0.1.5
67 (Bootfile name): netboot.xyz.efi


Choomai
(1 rep)
Apr 6, 2025, 04:41 AM
• Last activity: May 12, 2025, 12:17 PM
7
votes
1
answers
6195
views
How to debug DHCP timeout on WiFi connect?
I've recently moved to a place with public WiFi (so I don't have access to the router or their DHCP config), and am running into issues connecting with my Arch laptop. I've tried using both NetworkManager and netctl to connect, but both fail at getting a DHCP lease. It should be noted that every oth...
I've recently moved to a place with public WiFi (so I don't have access to the router or their DHCP config), and am running into issues connecting with my Arch laptop.
I've tried using both NetworkManager and netctl to connect, but both fail at getting a DHCP lease. It should be noted that every other device (Android and iOS phones, Windows and macOS laptops) does so without problems.
How do I go about debugging this? Am I missing a package, or am I connecting wrongly?
---
### NetworkManager
I use
nmcli
to connect:
$ nmcli dev wifi
* SSID MODE CHAN RATE SIGNAL BARS SECURITY
ssidOfWifi Infra 1 54 Mbit/s 52 ▂▄__ WPA2
ssidOfWifi Infra 13 54 Mbit/s 34 ▂▄__ WPA2
ssidOfWifi Infra 13 54 Mbit/s 22 ▂___ WPA2
$ nmcli dev wifi connect ssidOfWifi password passwordToWifi
Error: Connection activation failed: (5) IP configuration could not be reserved (no available address, timeout, etc.).
$ systemctl status NetworkManager
...
Jan 09 17:49:43 home NetworkManager: [1483980583.9385] device (wlp2s0): Activation: (wifi) Stage 2 of 5 (Device Configure) successful. Connected to wireless network 'ssidOfWifi'.
Jan 09 17:49:43 home NetworkManager: [1483980583.9386] device (wlp2s0): state change: config -> ip-config (reason 'none') [50 70 0]
Jan 09 17:49:43 home NetworkManager: [1483980583.9390] dhcp4 (wlp2s0): activation: beginning transaction (timeout in 45 seconds)
Jan 09 17:50:29 home NetworkManager: [1483980629.0055] dhcp4 (wlp2s0): state changed unknown -> timeout
Jan 09 17:50:29 home NetworkManager: [1483980629.0214] dhcp4 (wlp2s0): canceled DHCP transaction
Jan 09 17:50:29 home NetworkManager: [1483980629.0215] dhcp4 (wlp2s0): state changed timeout -> done
Jan 09 17:50:29 home NetworkManager: [1483980629.0220] device (wlp2s0): state change: ip-config -> failed (reason 'ip-config-unavailable') [70 120 5]
Jan 09 17:50:29 home NetworkManager: [1483980629.0223] manager: NetworkManager state is now DISCONNECTED
Jan 09 17:50:29 home NetworkManager: [1483980629.0233] device (wlp2s0): Activation: failed for connection 'ssidOfWifi'
Jan 09 17:50:29 home NetworkManager: [1483980629.0319] device (wlp2s0): state change: failed -> disconnected (reason 'none') [120 30 0]
Jan 09 17:50:29 home NetworkManager: [1483980629.0421] device (wlp2s0): set-hw-addr: set MAC address to AA:BB:CC:DD:EE:FF (scanning)
Jan 09 17:50:29 home NetworkManager: [1483980629.0453] sup-iface[0x1d5ec00,wlp2s0]: connection disconnected (reason -3)
Jan 09 17:50:29 home NetworkManager: [1483980629.0454] device (wlp2s0): supplicant interface state: completed -> disconnected
### Netctl
I use wifi-menu -o
to connect. This shows only one "ssidOfWifi", unlike nmcli
which shows one for each accesspoint.
$ sudo wifi-menu -o
Job for netctl@wlp2s0\x2dssidOfWifi.service failed because the control process exited with error code.
See "systemctl status "netctl@wlp2s0\\x2dssidOfNetwork.service"" and "journalctl -xe" for details.
$ journalctl -xe
...
Jan 09 23:10:34 home dhcpcd: wlp2s0: soliciting a DHCP lease
Jan 09 23:11:03 home dhcpcd: timed out
Jan 09 23:11:03 home dhcpcd: dhcpcd exited
Jan 09 23:11:03 home network: DHCP IPv4 lease attempt failed on interface 'wlp2s0'
Jan 09 23:11:03 home kernel: wlp2s0: deauthenticating from AA:BB:CC:DD:EE:FF by local choice (Reason: 3=DEAUTH_LEAVING)
Jan 09 23:11:03 home network: Failed to bring the network up for profile 'wlp2s0-ssidOfWifi'
Jan 09 23:11:03 home systemd: netctl@wlp2s0\x2dssidOfWifi.service: Main process exited, code=exited, status=1/FAILURE
Birjolaxew
(225 rep)
Jan 9, 2017, 10:23 PM
• Last activity: May 10, 2025, 07:05 PM
2
votes
2
answers
3401
views
How to automatically change DNS nameserver
My ISP's DNS server has problems resolving lots of important websites like google, github, gmail etc. As a hack I manually edited the /etc/resolv.conf file to Google's 8.8.8.8. But the changed file remodifies to my ISP's DNS service when there's a network change. How do I automatically set /etc/reso...
My ISP's DNS server has problems resolving lots of important websites like google, github, gmail etc. As a hack I manually edited the /etc/resolv.conf file to Google's 8.8.8.8.
But the changed file remodifies to my ISP's DNS service when there's a network change.
How do I automatically set /etc/resolv.conf to Google's DNS in the event of a network change and when I restart my computer using bash scripting.
I'm new to scripting on Linux. I'd need pointers on how to go about writing a script for this.
Thanks.
Bash
(21 rep)
Mar 15, 2020, 08:05 AM
• Last activity: May 4, 2025, 10:03 AM
2
votes
2
answers
2797
views
LXC ip allocation using DHCP
I'm trying to set up DHCP for my lxcontainers without using lxc-net. The reason for this decision is that I'd like to place my containers in different networks, such that they are unable to talk to each other by default. I have successfully created and run containers using static IPs assigned within...
I'm trying to set up DHCP for my lxcontainers without using lxc-net. The reason for this decision is that I'd like to place my containers in different networks, such that they are unable to talk to each other by default. I have successfully created and run containers using static IPs assigned within the containers' config file before, but I'd like to use a DHCP server on the host this time.
I've installed dnsmasq on my host and configured it like this:
# /etc/dnsmasq.d/dnsmasq.lxcbr.conf
domain=local.lxc,10.10.10.0/24
interface=lxcbr
dhcp-range=lxcbr,10.10.10.1,10.10.10.200,24h
dhcp-option=option:router,10.10.10.254
According to this the file is being loaded correctly:
root@host:~# service dnsmasq status
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled)
[...]
Feb 03 19:06:39 host dnsmasq: dnsmasq: syntax check OK.
Feb 03 19:06:39 host dnsmasq: started, version 2.72 cachesize 150
Feb 03 19:06:39 host dnsmasq: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect
Feb 03 19:06:39 host dnsmasq-dhcp: DHCP, IP range 10.10.10.1 -- 10.10.10.200, lease time 1d
Feb 03 19:06:39 host dnsmasq: reading /etc/resolv.conf
Feb 03 19:06:39 host dnsmasq: using nameserver upstream.nameserver.ip.here#53
Feb 03 19:06:39 host dnsmasq: using nameserver upstream.nameserver.ip.here#53
Feb 03 19:06:39 host dnsmasq: read /etc/hosts - 5 addresses
lxcbr is the host's interface in the container's network:
root@host:~# ifconfig
[...]
lxcbrBind Link encap:Ethernet HWaddr fe:60:7a:cc:56:64
inet addr:10.10.10.254 Bcast:10.10.10.255 Mask:255.255.255.0
inet6 addr: fe80::7a:56ff:fe82:921f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:92 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5688 (5.5 KiB) TX bytes:928 (928.0 B)
veth0 Link encap:Ethernet HWaddr fe:60:7a:cc:56:64
inet6 addr: fe80::fc60:7aff:fecc:5664/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:648 (648.0 B) TX bytes:648 (648.0 B)
veth0 is the container's veth interface:
# /var/lib/lxc/container
lxc.network.type = veth
lxc.network.name = veth0
lxc.network.flags = up
lxc.network.link = lxcbr
lxc.network.veth.pair = veth0
I assume I'm doing something very stupid but I've run out of ideas at this point.
I appreciate your help,
Christopher
Cyclonit
(161 rep)
Feb 3, 2016, 06:20 PM
• Last activity: May 3, 2025, 04:02 PM
1
votes
1
answers
2891
views
Disable systemd-resolved to free up port 53 and use DNS servers provided by dhcp
I will be running a Pi-hole server in a docker container, so I have freed up port 53 by setting`DNSStubListener=no` in `/etc/systemd/resolved.conf` and restarting `systemd-resolved`. This has freed up port 53, but now DNS doesn't work. I get `;; connection timed out; no servers could be reached` Loo...
I will be running a Pi-hole server in a docker container, so I have freed up port 53 by setting
DNSStubListener=no
in /etc/systemd/resolved.conf
and restarting systemd-resolved
.
This has freed up port 53, but now DNS doesn't work. I get ;; connection timed out; no servers could be reached
Looking at Network Settings from the desktop, I see 1.1.1.1 and 8.8.8.8 as the DNS servers assigned by DHCP as currently configured, but how do I get my system to use these?
**UPDATE1:**
/etc/resolv.conf has this:
nameserver 127.0.0.53
options edns0 trust-ad
search domain.local
neildeadman
(121 rep)
Dec 9, 2021, 12:36 PM
• Last activity: Apr 30, 2025, 01:05 AM
-1
votes
0
answers
64
views
setting up PXE and DHCP server on RHEL VM
So I am trying to setup a kickstart server with pxeboot and dhcp server (for ks) on RHEL 8 VM. When I capture network traffic I do not see any pxe/tftp traffic coming to the VM or the host.... I tried following: host: RHEL 8.10 kickstart server: RHEL 8.10 VM client: RHEL 7 physical host on other sub...
So I am trying to setup a kickstart server with pxeboot and dhcp server (for ks) on RHEL 8 VM. When I capture network traffic I do not see any pxe/tftp traffic coming to the VM or the host....
I tried following:
host: RHEL 8.10
kickstart server: RHEL 8.10 VM
client: RHEL 7 physical host on other subnet using pxeboot
on server side, I opened ports as follows on kvm host and VM both:
# firewall-cmd --add-service dhcp --perm
# firewall-cmd --add-service tftp --perm
# firewall-cmd --permanent --new-policy tftp-client-data
# firewall-cmd --permanent --policy tftp-client-data --add-ingress-zone HOST
# firewall-cmd --permanent --policy tftp-client-data --add-egress-zone ANY
# firewall-cmd --permanent --policy tftp-client-data --add-service tftp
# firewall-cmd --reload
All config is on KVM VM acting as kickstart server. Only reason i included/mentioned KVM host in this post is - I suspect we need some config there too... I am not sure.
dhcp and tftpserver service is enabled and running just fine.
dhcp.conf file has 2 subnets defined. 1 for local VM (to get the dhcp server up and running) and one for client. (If you do not have subnet for dhcp server itself server will not start)
When I boot the client with PXE boot option. I can see it is waiting for pxe / tftp server but I do not see any traffic on the host or VM. and eventually client times out.
from client:
What can I check on host and VM side?
Thank you.

Rajeev
(256 rep)
Apr 24, 2025, 11:33 PM
• Last activity: Apr 25, 2025, 04:02 PM
3
votes
1
answers
11945
views
Set up Debian networking bridge with DHCP
After a recent bout of package upgrades (but still within the stretch release) my bridge networking to support libvirt VMs seems to have died - the DHCP server does not send an IP to the host nor does the host have any network connectivity. Previously my `/etc/network/interfaces` file worked great (...
After a recent bout of package upgrades (but still within the stretch release) my bridge networking to support libvirt VMs seems to have died - the DHCP server does not send an IP to the host nor does the host have any network connectivity. Previously my
/etc/network/interfaces
file worked great (as has been recommended in the the Debian wiki ):
iface eth0 inet manual
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
Alas, when I try to bring it up using ifup br0
or systemctl restart networking
I get very unhelpful log messages like ifup: failed to bring up eth0
.
Most strangely, if I set a static IP on the br0
interface everything works great, but I'd like to configure my static IPs in the router rather than the host OS.
This is the workaround static IP configuration, closely modeled after the [libvirt networking guide](https://jamielinux.com/docs/libvirt-networking-handbook/bridged-network.html) .
iface eth0 inet manual
auto br0
iface br0 inet static
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
hwaddress ether e0:3f:49:eb:7f:35
address 192.168.1.140
gateway 192.168.1.1
broadcast 192.168.1.255
netmask 255.255.255.0
Also, if I remove the bridge entirely and just configure eth0
to directly use dhcp the host will receive an address from the router.
Any thoughts on what I can do to further troubleshoot or fix the issue? Thanks!
Aaron Kanter
(31 rep)
Jun 29, 2020, 08:54 AM
• Last activity: Apr 8, 2025, 01:13 AM
Showing page 1 of 20 total questions