0

Before installing /etc/network/interfaces, both ports on the PC (enp1s0 and enp2s0) could ping other IPs on the network and google. After installing /etc/network/interfaces and setting the IP address, only the static IP address will ping google and other IPs on the network. Regardless of the different combinations of static and dhcp, there is only one port that can ping other IPs on the network and google and one port that cannot ping other IPs on the network and google. If I comment out all lines in /etc/network/interfaces and reboot, both ports can ping other IPs on the network and google. I have determined that the problem stems from /etc/network/interfaces. Does anyone know how to fix this problem?

ip a output:

root@jen:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether c4:00:ad:6f:34:7f brd ff:ff:ff:ff:ff:ff
    inet 10.180.198.32/23 brd 10.180.199.255 scope global dynamic enp1s0
       valid_lft 2953sec preferred_lft 2953sec
    inet6 fe80::c600:adff:fe6f:347f/64 scope link
       valid_lft forever preferred_lft forever
3: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether c4:00:ad:6f:34:80 brd ff:ff:ff:ff:ff:ff
    inet 10.180.198.23/23 brd 10.180.199.255 scope global enp2s0
       valid_lft forever preferred_lft forever
    inet6 fe80::c600:adff:fe6f:3480/64 scope link
       valid_lft forever preferred_lft forever

/etc/network/interfaces configuration:

root@jen:~# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
#The loopback network interface
auto lo
iface lo inet loopback

#The primary netowrk interface
allow-hotplug enp1s0
iface enp1s0 inet dhcp

allow-hotplug enp2s0
iface enp2s0 inet static
        address 10.180.198.23/23
        gateway 10.180.198.1

Ping when enp1s0 port is used (no cable in enp2s0 port):

root@jen:~# ping 10.180.198.90
PING 10.180.198.90 (10.180.198.90) 56(84) bytes of data.
64 bytes from 10.180.198.90: icmp_seq=1 ttl=64 time=0.300 ms
64 bytes from 10.180.198.90: icmp_seq=2 ttl=64 time=0.477 ms
64 bytes from 10.180.198.90: icmp_seq=3 ttl=64 time=0.498 ms
64 bytes from 10.180.198.90: icmp_seq=4 ttl=64 time=0.537 ms
^C
--- 10.180.198.90 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3069ms
rtt min/avg/max/mdev = 0.300/0.453/0.537/0.090 ms

Ping when enp2s0 port is used (no cable in enp1s0 port):

root@jen:~# ping 10.180.198.90
PING 10.180.198.90 (10.180.198.90) 56(84) bytes of data.
From 10.180.198.23 icmp_seq=2 Destination Host Unreachable
From 10.180.198.23 icmp_seq=3 Destination Host Unreachable
From 10.180.198.23 icmp_seq=4 Destination Host Unreachable
^C
--- 10.180.198.90 ping statistics ---
6 packets transmitted, 0 received, +3 errors, 100% packet loss, time 5122ms pipe 3

ip route with Ubuntu configuration (both ports working as wanted):

root@jen-Default-string:~# ip route
default via 10.180.198.1 dev enp1s0 proto dhcp metric 100
default via 10.180.198.1 dev enp2s0 proto dhcp metric 101
10.180.198.0/23 dev enp1s0 proto kernel scope link src 10.180.198.21 metric 100
10.180.198.0/23 dev enp2s0 proto kernel scope link src 10.180.198.22 metric 101
169.254.0.0/16 dev enp1s0 scope link metric 1000

ip route with /etc/network/interfaces configuration:

root@jen-Default-string:~# ip route
default via 10.180.198.1 dev enp2s0 onlink
10.180.198.0/23 dev enp2s0 proto kernel scope link src 10.180.198.23
10.180.198.0/23 dev enp1s0 proto kernel scope link src 10.180.198.33
169.254.0.0/16 dev enp2s0 scope link metric 1000

enp1s0 and enp2s0 renamed in cat /var/log/kern.log:

Jun 29 08:57:02 jen-Default-string kernel: [ 0.824287] r8169 0000:02:00.0 eth1: RTL8168g/8111g, c4:00:ad:6f:34:80, XID 4c0, IRQ 127 
Jun 29 08:57:02 jen-Default-string kernel: [ 0.824288] r8169 0000:02:00.0 eth1: jumbo features [frames: 9194 bytes, tx checksumming: ko] 
Jun 29 08:57:02 jen-Default-string kernel: [ 0.828202] r8169 0000:01:00.0 enp1s0: renamed from eth0 
Jun 29 08:57:02 jen-Default-string kernel: [ 0.851441] r8169 0000:02:00.0 enp2s0: renamed from eth1
13
  • are both these interfaces on the same network, using the same gateway? Jun 28, 2021 at 18:46
  • @FrankThomas Both interfaces are on the same network and are using the same gateway.
    – user2023
    Jun 28, 2021 at 18:51
  • Vocabulary: enp1s0 and enp2s0 are network interfaces (cards) (NICs). Then addresses set on those interfaces don't equal those interfaces. Usually by default only one interface gets used to reach Internet, even with addresses on other interfaces. Now without any value about any setting in your question, it's a bit difficult to guess what happened. You should provide more data.
    – A.B
    Jun 28, 2021 at 20:46
  • what does your route table look like both with and without the configured interfaces file? generally speaking, having two interfaces on the same network doesn't help you very much, and potentially causes issues at layer2. servers will often "Bond" or "Team" interfaces into a single logical interface with 2x bandwidth, but absent that, you don't get a lot out of the configuration you described. the os will only use 1 nic for most purposes. Jun 28, 2021 at 23:07
  • It's hard to comment on configuration that I don't know. If you suspect a problem with /etc/network/interfaces, I suggest you share the file. Jun 29, 2021 at 0:41

1 Answer 1

0

I was able to fix the problem. In the Network settings on the GUI under the Wired connections, all criteria need to be filled. Link speed, IPv4 address, IPv6 address, hardware address, default route, and dns. This allowed me to ping other IP addresses in my network from both ports.

There was an issue with configuring /etc/network/interfaces and disabling the NetworkManager. This made the network connection not fully work (one port can ping other IP addresses, one port cannot) even if it appeared in the settings as if it should work. I could get the connection to work after messing around with it in the GUI, but after reboot, it would not work again.
How I did this configuration between /etc/network/interfaces and /etc/NetworkManager/NetworkManager.conf -->

First, you configured /etc/network/interfaces (example configuration)

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

#The loopback network interface
auto lo
iface lo inet loopback

#The primary netowrk interface
allow-hotplug enp2s0
iface enp2s0 inet static
       address 10.180.198.22/23
       gateway 10.180.198.1
       netmask 255.255.254.0
       dns-nameservers 10.180.0.14
       dns-nameservers 10.116.0.14

allow-hotplug enp1s0
iface enp1s0 inet static
       address 10.180.198.23/23
       gateway 10.180.198.1
       netmask 255.255.254.0
       dns-nameservers 10.180.0.14
       dns-nameservers 10.116.0.14

Next, you change manage=false to manage=true in /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=true

[device]
wifi.scan-rand-mac-address=no

However, I do think this is reliable and there will be some challenges with this type of configuration between /etc/network/interfaces and /etc/NetworkManager/NetworkManager.conf. There could be something else that I was missing as to why this configuration didn't work for me after rebooting.

If you want to change the address from the NetworkManager directly while /etc/network/interfaces is disabled (nothing in the file), here are the steps: First, find the connection name. Use this command:

nmcli con show

Next, change the IP address in the command line:

sudo nmcli con mod "Connection name" ipv4.addresses xxx.xxx.xxx.xxx/xx

xxx.xxx.xxx.xxx/xx = the IP address that you want to change it to.

Also, make sure that in /etc/NetworkManager/NetworkManager.conf this is the what is listed in the file:

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

You must log in to answer this question.

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