Score:0

How to configure DHCP and Static interfaces on Ubuntu 18.04.6 - Destkop

ml flag

/etc/network/interfaces contains the below:

source-directory /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    gateway 192.168.1.1

auto eth0
iface eth0 inet dhcp

I have an on-board ethernet adapter that I want to be set for DHCP and also a USB to Ethernet adapter that I want set to 192.168.1.10

If the USB adapter is NOT plugged in on boot, I receive an IP for eth0.

If the USB adapter IS plugged in on boot, I get a static IP 192.168.1.10 for eth1 but no DHCP IPv4 address for eth0

I spent days on this already, any help is appreciated.

EDIT1: this is the /var/log/syslog output with grep applied (grep -E "dhclient|eth0|eth1")

USB to Ethernet adapter is plugged in on boot (no DHCP address assigned to eth0). syslog output:

Mar  6 12:12:36 jetson kernel: [    2.154873] r8152 2-1.3:1.0 eth0: v2.09.00 (2017/08/21)
Mar  6 12:12:36 jetson kernel: [    2.154878] r8152 2-1.3:1.0 eth0: This product is covered by one or more of the following patents:
Mar  6 12:12:38 jetson systemd[1]: Started ifup for eth1.
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.4103] guessed connection type (eth1) = 802-3-ethernet
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.4104] update_connection_setting_from_if_block: name:eth1, type:802-3-ethernet, id:Ifupdown (eth1), uuid: 7b635ed6-2640-7ad8-675d-744db12dd9fa
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.4109] adding eth1 to connections
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.4109] adding iface eth1 to eni_ifaces
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.4129] devices added (path: /sys/devices/1003000.pcie/pci0000:00/0000:00:02.0/0000:01:00.0/net/eth1, iface: eth1)
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.4133] devices added (path: /sys/devices/70090000.xusb/usb2/2-1/2-1.3/2-1.3:1.0/net/eth0, iface: eth0)
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.4133] device added (path: /sys/devices/70090000.xusb/usb2/2-1/2-1.3/2-1.3:1.0/net/eth0, iface: eth0): no ifupdown configuration found.
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.4994] keyfile: new connection /run/NetworkManager/system-connections/netplan-eth0.nmconnection (75a1216a-9d1a-30cd-8aca-ace5526ec021,"netplan-eth0")
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.5210] dhcp-init: Using DHCP client 'dhclient'
Mar  6 12:12:38 jetson kernel: [    5.348192] eth1: 0xffffff800d589000, 48:b0:2d:5c:39:cd, IRQ 407
Mar  6 12:12:38 jetson avahi-daemon[4207]: Joining mDNS multicast group on interface eth1.IPv4 with address 192.168.1.10.
Mar  6 12:12:38 jetson avahi-daemon[4207]: New relevant interface eth1.IPv4 for mDNS.
Mar  6 12:12:38 jetson avahi-daemon[4207]: Registering new address record for 192.168.1.10 on eth1.IPv4.
Mar  6 12:12:38 jetson kernel: [    5.451629] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.6964] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/3)
Mar  6 12:12:38 jetson NetworkManager[4189]: <info>  [1678133558.7150] manager: (eth1): new Ethernet device (/org/freedesktop/NetworkManager/Devices/4)
Mar  6 12:12:39 jetson networkd-dispatcher[4254]: ERROR:Unknown state for interface NetworkctlListState(idx=3, name='eth0', type='ether', operational='n/a', administrative='unmanaged'): n/a
Mar  6 12:12:39 jetson networkd-dispatcher[4254]: ERROR:Unknown state for interface NetworkctlListState(idx=4, name='eth1', type='ether', operational='n/a', administrative='unmanaged'): n/a
Mar  6 12:12:39 jetson NetworkManager[4189]: <info>  [1678133559.3797] devices added (path: /sys/devices/70090000.xusb/usb2/2-1/2-1.3/2-1.3:1.0/net/eth0, iface: eth0)
Mar  6 12:12:39 jetson NetworkManager[4189]: <info>  [1678133559.3798] device added (path: /sys/devices/70090000.xusb/usb2/2-1/2-1.3/2-1.3:1.0/net/eth0, iface: eth0): no ifupdown configuration found.
Mar  6 12:12:39 jetson NetworkManager[4189]: <info>  [1678133559.3813] device (eth0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Mar  6 12:12:39 jetson kernel: [    6.159876] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Mar  6 12:12:39 jetson kernel: [    6.176569] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Mar  6 12:12:42 jetson NetworkManager[4189]: <info>  [1678133562.7772] device (eth1): carrier: link connected
Mar  6 12:12:42 jetson kernel: [    9.554106] r8168: eth1: link up
Mar  6 12:12:42 jetson kernel: [    9.554147] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
Mar  6 12:12:43 jetson avahi-daemon[4207]: Joining mDNS multicast group on interface eth1.IPv6 with address fe80::4ab0:2dff:fe5c:39cd.
Mar  6 12:12:43 jetson avahi-daemon[4207]: New relevant interface eth1.IPv6 for mDNS.
Mar  6 12:12:43 jetson avahi-daemon[4207]: Registering new address record for fe80::4ab0:2dff:fe5c:39cd on eth1.*.

EDIT2:

This is my netplan config

network:
  ethernets:
    eth0:
      match:
        macaddress: my_mac_for_onboard_ethernet
      dhcp4: true
    eth1:
      dhcp4: false
      addresses: [192.168.1.10/24]
  version: 2

EDIT3 Here is my updated yaml file - currently no DHCP address on eth0


network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true

    eth1:
      addresses:
        - 192.168.1.10/24
      gateway4: 192.168.1.1
Simon Sudler avatar
us flag
The `/etc/network/interfaces/` file look alright. You should check the `/var/log/syslog`. watch out for `dhclient` messages, renaming of network interfaces, etc... if you want help on this, [edit](https://askubuntu.com/posts/1458064/edit) your question and include the logs.
chili555 avatar
cn flag
The `/etc/network/interfaces` method is deprecated in Ubuntu 17.10 and later. Its function is now handled in netplan. Is this a desktop (using Network Manager) or server installation? Welcome to Ask Ubuntu.
chili555 avatar
cn flag
What does this suggest that your netplan file should read? `cat /usr/share/doc/netplan/examples/static.yaml`
tadams avatar
ml flag
a nameserver block? I assumed that was handled on the remote DHCP server and required no config on the client side.
chili555 avatar
cn flag
The DHCP server doesn't supply DNS nameservers to interfaces declared to be static. Also please check renderer and route.
tadams avatar
ml flag
I added renderer, but not sure what you meant by route
tadams avatar
ml flag
The route for eth0 (DHCP assigned) appears to be missing from `ip route` command. When I unplug the eth1 (USB adapter) and reboot, the `ip route` command returns routes for DHCP. Do you know why the routes for eth0 would disappear just because a USB Adapter is plugged in? I would like to avoid declaring the routes in netplan - I want to take the defaults from the DHCP server
chili555 avatar
cn flag
Netplan won't work if you don't follow its conventions and you certainly can't do what you are trying to do with Network Manager. Please paste the following: `cat /usr/share/doc/netplan/examples/static.yaml` and also: `cat /etc/netplan/*.yaml` Paste the results here and give us the link: http://paste.ubuntu.com
chili555 avatar
cn flag
Are your interfaces eth0 and eth1 or are they enp3s0 and enp3s1? `ip a`
tadams avatar
ml flag
They are eth0 and eth1, I tried both but changed the config to eth0 and eith1
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.