I am trying to create a dhcp server with iproute2 and the DHCP part is working fine, yet the clients don't get any internet.

The host is getting internet from network and functions as a router/DHCP-server for the subnet

The clients will get the ip's from the correct ip address range, when I connect them to the same interface as the host machine.

This is my network config.

# Starting interfaces
ip link set dev eth0 up 
ip link set dev eth1 up

# Assigning addresses to interface 
ip addr add "" dev eth0 brd +
ip addr add "" dev eth1 brd +

# Specifying how eth0 will get his internet.
ip route add default dev eth0 via "" scope global

My question is how can I route the internet connection from eth0 to eth1 as well.

I was trying to add the route like this:

ip route add "" dev eht0

and similar but it says wrong prefix when I have "" if I change 1 to 0 then I get another error that File exists or Nexthop has invalid gateway.

Thank you in advance

Also as a note: I don't know if it is important, but both eth0 and eth1 is bridged into the machine which is running on libvirt.

  • ponder xyproblem.info and please explain in plain words what you are trying to achieve, not how (because it's not working). Giving an example involving "clients", router (and maybe router's router) and Internet would help. Also where is DHCP involved if anywhere?
    – A.B
    Commented May 10, 2021 at 19:08
  • Thanks, Now I have made my situation/environment and question more clear. The machine itself is functioning as a DHCP server, for anyone who connects to the interface eth1. Should I include my DHCP configuration files as well?
    – mama
    Commented May 10, 2021 at 19:29

2 Answers 2


You need to do ip route add default via dev eht0 on clients or push the route through DHCP server (depends on which one do you use, you don't specify that in your question). Also make sure you have ip_forwarding enabled (/proc/sys/net/ipv4/ip_forward = 1) and make sure you have masquarading (NAT) enabled via iptables/nftables. Alternatively if you control the machine with IP, you can add there ip route add via and avoid masquarading.

  • Thank you. I have access to all the computers, and is the same computer that I am doing the configuration on. When I try ip route add via I get error File exists, and if I try ip route it says that the route for dev eth1 proto kernel scope link src
    – mama
    Commented May 11, 2021 at 11:40

It turns out that I forgot to disable the default firewall and network manager on my system so I was running SuSeFirewall2 and wicked in the background which was messing up with my settings.

my final network setup ended up like this


case "$1" in
        echo "Starting the network"

        echo "search my.dns.server.ext" > /etc/resolv.conf
        echo "nameserver" >> /etc/resolv.conf

        ip addr add "" dev eth0 brd +
        ip addr add "" dev eth1 brd +
        ip link set dev eth0 up
        ip link set dev eth1 up
        ip route add default via scope global

        echo 1 > /proc/sys/net/ipv4/ip_forward

        echo "Stopping the network"
        ip addr flush eth0
        ip addr flush eth1
        ip link set dev eth0 down 
        ip link set dev eth1 down 
        $0 stop
        $0 start
        echo "Usage $0 [start|stop|restart]"

I also had to manually setup DNS in /etc/resolv.conf after disabeling wicked, but now it works as a charm.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .