bullseye - how to configure eth1 for LAN only ?

Apr 24, 2023 Last reply: 3 years ago 57 Replies

Hello all,



Using bullseye lite (terminal only) and DHCP (dhclient) I'm trying to configure two network interfaces, connected to different networks with their own routers.



I would like to configure one or both of the eth? interfaces as a LAN only connection, meaning without a "default gateway" and/or DNS server adresses and such.



I've found some information about what to edit in /etc/dhcp/dhclient.conf, but after rebooting and checking the output of "route" I still see a "gateway" entry for eth1.



Does anybody know what to add/remove/change in that dhclient.conf file to get it to work ?



Remark: I've also seen suggestions to just give eth1 a high metric (so the eth0 gateway is considered first), but that doesn't work for me as eth0 might not be always available.



Regards, Rudy Wieser



Do you use NetworkManager? Or dhclient directly? Systemd?

This gives suggestions for both NM and dhclient:

formatting link
However systemd doesn't use dhclient.conf (I am told). See here:
formatting link
answer mentions systemd.

HIH

Chris,

I tried "nmcli" but got the response that NetworkManager wasn't running.

I do have a /etc/dhcp/dhclient.conf file, but I'm not sure at all if its actually used (editing it doesn't seem to change anything).

As for systemd ? It looks like it, as I have a "/etc/systemd" folder.

So, I've got two outof three, with one maybe.

Thats one of the links I found from which I applied the "Another way: dhclient.conf" suggstion. Alas, I still got a "default gateway" on eth1.

Yep, found that one too. The second post (by Nils Toedtmann) says the same as your link. :-)

I read that too, but although I can find the "/etc/systemd/network" folder itself I simply do not have enough information to be sure what the "*.interface" name should be. Next to that I do not see, under "[DHCP]", any mentioning of a gateway, but to see the "lets use a high metric" hack that I, as mentioned, can't use. :-\

In short, the presence of a "dhclient.conf" *and* "/etc/systemd" makes me quite unsure which one actually gouverns the network configuration. Hence my post.

Regards, Rudy Wieser

OK, no NetworkManager.

Are you sure you're using dhclient? What does `ps ax | grep dhc` say?

Just looked at my 11.6 install. It uses dhcpcd

If yours does too, try putting

interface eth1 nogateway

at the end of /etc/dhcpcd.conf

Chris,

Reasonably sure : I used

/var/log/syslog | grep -Ei 'dhcp'.

formatting link
to check, and had a number of lines mentioning "dhcpcd" with one of them mentioning "adding default route", showing the IP of the router servicing the eth1 LAN

It says

/user/sbin/dhcpcd -w -q

Could you tell me how you checked that ?

That does seem to have done the trick. Thanks.

It also means I have to do a bit more googeling, but now focussed on that paricular file.

A question though : if that file is there to configure the interfaces, what than is the "/etc/dhcp/dhclient.conf" file about ? Do you know ?

And strangely enough, I've only seen that "dhcpcd.conf" file being mentioned once,

formatting link
but must admit I skipped it as it was talking about setting a fixed IP.

Regards, Rudy Wieser

that's the line from /usr/lib/systemd/system/dhcpcd.service

ps ax | grep dhc

it is to configure dhclient

that's coz raspbian uses dhcpcd

dhclient and dhcpcd are 2 *different* methods of automatically assigning ip adresses. dhclient is not used by stock raspbian.

look at /usr/lib/systemd/system/dhcpcd.service systemctl status dhcpcd.service

Chris,

:-) That much I already assumed.

Well, that explains everything. I've been focussing on and modifying an unused configuration file. No wonder nothing seemed to work. :-(

I must say that I don't quite understand why bullseye *lite* would carry two seperate network configuration methods - one of which it doesn't even use - while not bothering to including supporting files for when someone (like me) wants to do a bit of GPIO or graphics using GCC.

I've seen post about dhcpcd dated as far back as 2011. I would have expected that my two/three day stint googeling would have popped up that name a few more times - Especially in relation to the RPi by people having a similar "how to configure the network" problem.

Than again, how many people would want to create a "LAN only" interface ...

Thanks. I just did. Can't say I understand what whats in it means though. More to google I guess. :-)

Apart from recognising the the syslog entries at the bottom the same goes here.

Thanks for the help and info.

Regards, Rudy Wieser

I haven't come across any distro that doesn't include both. I've always thought the lite moniker just meant no X

I do it regularly!

If I'd looked at my installation earlier I'd probably have twigged you were using dhcpcd not dhclient.

The Exec line says what it does - starts dhcpcd. Type say it forks and Restart tells it to restart if it crashes or is stopped.

The rest of the file just sets up the environment.

Chris,

My own assumption went a bit further than that : minimal default installed software, less stuff running by default. Which fit me just fine, as I'm using it on am ancient, rather slow RPi v1. (yes, I did try to tun a graphical environment first. It was painfull. :-) )

I did see the "dhcpcd" name in the syslog, but as I didn't (yet) know about whats what I failed to recognise it for what it was ...

A new question though (if you don't mind) : I've been trying to disable ipv6 too, and reading the man page for dhcpcd.conf I saw that I could use "ipv4only".

I've put that just above the "interface eth1" line (assuming that it would than work for all interfaces), but "ifconfig" still shows ipv6 adresses for both "eth1" as well as "lo" (eth0 is disconnected). I also tried to put it under "interface eth1" and got the same result. As such I'm not at all sure what that "ipv4only" is supposed to do (if anything).

I get the feeling (fuelled by some googeling results) that ipv6 needs to be disabled elsewhere. But although googeling for a way to do so turns up some results, I'm not at all sure if any of it applies to bullseye (most of it is old).

Besides that, I would also would like to have some more information about (possibly) disabeling/changing DNS and other stuff dhpdcd seems to ask the dhcp server for* (even when DNS servers can't be reached without a default gateway).

  • I had a windows machine capture both the request as well as the response. The RPi asked for a lot, but got only a little ...

In short : do you know of any source of info (website) which explains the network configuration, focussed on what is currently used by bullseye ?

Regards, Rudy Wieser

DHCP is a noddy default setup for a client machine that is connected to well maintained environment. If you want other than the defaults I would suggest either using static IP configuration (NO DHCP) or doing some work on the DHCP server - typically a router these days. Its quite hard to have a *partial* DHCP configuration.

Your router may support different LAN address with different DHCP configurations, to disable default route and DNS instances.

Try: noipv6rs noipv6

According to the BSD DHCPCD man page:

noipv6 Don't solicit or accept IPv6 Router Advertisements and DHCPv6. noipv6rs Don't solicit or accept IPv6 Router Advertisements.

This seems to say that noipv6 includes noipv6rs, but Archwiki says putting in both (in that order) works.

Have you looked at man dhcpcd.conf?

Arch wiki is a valuable resource e.g.

formatting link
usually better than alternatives.

Don't get too hung up on the raspbian/bullseye focus. dhcpcd configuration is dhcpcd configuration no matter which distro you're using. Even the systemd invocation used by debian and thus raspbian is just a straight invocation of dhcpcd. As previous, try the archwiki.

I thought the OP was trying to set up a DHCP client, not a server?

What sort of ipv6 addresses ? If it is only link local ipv6 addresses (starting fe80::) then they don't come from DHCPCD but from IPv6 neighbour discovery and are probably quite hard to get rid of but they're only valid on a LAN segment so I wouldn't worry about them too much.

dhcpcd is client, isn't it?

Thought it was the server

dhclient is the client. But I think there are many clients now. What with systemd and network manager its all a muddle.

No. See previous. dhcpcd and dhclient are *different* dhcp clients. dhclient is supplied by the ISC. dhclient is not normally used by debian, slackware (or any other distros I use). They all use dhcpcd. Even the systemd implementation used in debian uses dhcpcd. See /usr/lib/systemd/system/dhcpcd.service

formatting link
says "ISC plans to end maintenance of the ISC DHCP client and relay by the end of Q1, 2022." Hence dhclient is end-of-life (IMHO). I don't know about NetworkManager (or nmcli), I don't use it. A quick look on Archwiki and /usr/lib/systemd/system/NetworkManager.service says it is dbus based.

It seems there are 2 ways to totally disable ipv6

formatting link

1) Pi only: add 'ipv6.disable=1' to end of line in /boot/cmdline.txt 2) Generally, a) if using sysctl: put a file in /etc/sysctl.d/ containing net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 b) if not using sysctl, add echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6 echo 1 > /proc/sys/net/ipv6/conf/lo/disable_ipv6 to end of (for e.g.) /etc/rc.local

Both methods will disable all ipv6 including link-local NetworkManager has a "disable" option under ipV6, too.

Ubuntu is still using dhclient, isn't it?

No idea. Does `ps ax | grep dhc` give a clue? Does nmcli work? -> uses NetworkManager

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required