# Network configuration from the gentoo handbook?

## orion777

Good day. The problem is that gentoo system has NetworkManager. NetworkManager starts dhclient (if required) and stores its configuration in the /etc/NetworkManager/system-connections (if you do it through, for example, nmtui). 

However, network configuration file /etc/conf.d/net , as required by the handbook https://wiki.gentoo.org/wiki/Handbook:X86/Full/Networking#Using_the_old-style_kernel_naming , does not exists at all (whereas /etc/init.d contains some scripts inside and I don't know does the commands like ln -s net.lo net.eth0  were implemented).

I wish to build my own router as per https://wiki.gentoo.org/wiki/Ethernet_plus_WiFi_Bridge_Router_and_Firewall . This handbook also use  /etc/conf.d/net (which does not exists in my system) instead of NetworkManager conf files. 

So, what I have to do in order to implement instruction? Delete NetworkManager at first and then implement this https://wiki.gentoo.org/wiki/Handbook:X86/Full/Networking#Using_the_old-style_kernel_naming and finally this https://wiki.gentoo.org/wiki/Ethernet_plus_WiFi_Bridge_Router_and_Firewall ?

----------

## NeddySeagoon

orion777,

Choose NetwerkManger or the init scrips.  Trying to use both will get you in a mess as they are unaware of each other.

The interface names are not important. Discover what they are and use them consistently everywhere.

I prefer the kernel naming because that's what I learned a long time ago.

The "Persistent Device Naming" has just swapped one set of corner cases for another. Its just different rather than an improvement.

Both ways work and are equally correct.

----------

## orion777

So I can use eth0 / wlan0 names in the scripts, right?

I will try to use your gentoo on rpi3 to build the router with MPTCP implementation, want to see will it work or not.

----------

## charles17

 *orion777 wrote:*   

> However, network configuration file /etc/conf.d/net , as required by the handbook 

 

should be provided by netifrc.

----------

## NeddySeagoon

orion777,

To get the old names add 

```
net.ifnames=0
```

to the kernel command line.

On a Raspberry Pi you will get the old names anyway as the Persistent Device Names depend on the PCI bus IDs.

The Pi does not have PCI. 

MPTCP implementation?

That's been done on a Pi. From memory someone was using two 4G sticks and the kernel MPTCP patch.

----------

## orion777

 *NeddySeagoon wrote:*   

> orion777,
> 
> To get the old names add 
> 
> ```
> ...

 

Okay, where to specify? In the /boot/config.txt string net.ifnames=0 gives no effect.

Also please note than ifconfig -a returns same eth / wlan like names..

 *Quote:*   

> MPTCP implementation?
> 
> That's been done on a Pi. From memory someone was using two 4G sticks and the kernel MPTCP patch.

 

Yes, I know this guy! That was me   :Embarassed:  But please be careful that when mptcp kennel and modulesinstall were used, old (standard) kernel will not work as it should be (also has been testen on laptop with grub)

----------

## NeddySeagoon

orion777,

It would go in /boot/cmdline.txt on a Pi but its not required.

There is nowhere to get the Persistent Interface names from so you will always have ethX and wlanY style names anyway.

----------

## krinn

Ok so it's not need for that user, but for the story:

```
ls /sys/class/net

eth0  lo

ls /etc/udev/rules.d/ -l

...

-rw-r--r-- 1 root root    0 27 juil.  2017 80-net-name-slot.rules

dmesg | grep command

[    0.000000] Kernel command line: clocksource=hpet root=/dev/sdb2 pti=on

[binary   R    ] sys-fs/eudev-3.2.5::gentoo  USE="hwdb introspection kmod -rule-generator (-selinux) -static-libs {-test}" ABI_X86="32 (64) (-x32)" 0 KiB

```

So still good with the empty file too.

----------

## orion777

Good day! Now I can't force name server to work.. Static or DHCP configuration returns same result (NetworkManager has been removed from rc)

```
pi64 ~ # ping google.lv

ping: google.lv: Temporary failure in name resolution

pi64 ~ # cat /etc/conf.d/net

#eth0

#config_eth0="dhcp"

config_eth0="192.168.1.115 netmask 255.255.255.0"

routes_eth0="default via 192.168.1.1"

dns_servers_eth0="8.8.8.8 8.8.4.4"

```

----------

## younggeorge

Gentoo's RC system now knows about that interface. All the network interfaces are configured in /etc/conf.d/net. Below is a sample configuration for DHCP and static addresses.

----------

## freke

 *orion777 wrote:*   

> Good day! Now I can't force name server to work.. Static or DHCP configuration returns same result (NetworkManager has been removed from rc)
> 
> ```
> pi64 ~ # ping google.lv
> 
> ...

 

Can you ping 8.8.8.8 and 8.8.4.4?

You're sure your interface is named eth0? (what does ifconfig say?)

----------

## NeddySeagoon

orion777,

One step at a time.  What does 

```
ifconfig -a
```

 show

----------

## orion777

So, I put back NetworkManager into autostart. As can be seen, the ping is able to ping google.lv even after NetworkManager has been stopped, but the system was not rebooted.

```
pi64 ~ # ps -ax | grep NetworkManager

 1868 ?        Ssl    0:00 /usr/sbin/NetworkManager --pid-file /run/NetworkManager/NetworkManager.pid

 2053 ?        S      0:00 /sbin/dhclient -d -q -sf /usr/libexec/nm-dhcp-helper -pf /run/dhclient-eth0.pid -lf /var/lib/NetworkManager/dhclient-67c07402-fa8d-3137-a466-9b22cfcc2fd6-eth0.lease -cf /var/lib/NetworkManager/dhclient-eth0.conf eth0

 2896 pts/0    S+     0:00 grep --colour=auto NetworkManager

pi64 ~ # ping 8.8.8.8

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=24.3 ms

64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=23.6 ms

^C

--- 8.8.8.8 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 3ms

rtt min/avg/max/mdev = 23.571/23.922/24.273/0.351 ms

pi64 ~ # ping 8.8.4.4

PING 8.8.4.4 (8.8.4.4) 56(84) bytes of data.

64 bytes from 8.8.4.4: icmp_seq=1 ttl=119 time=28.7 ms

64 bytes from 8.8.4.4: icmp_seq=2 ttl=119 time=25.2 ms

^C

--- 8.8.4.4 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 3ms

rtt min/avg/max/mdev = 25.208/26.974/28.741/1.774 ms

pi64 ~ # ifconfig -a

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.115  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::4841:5b11:68e6:b2cb  prefixlen 64  scopeid 0x20<link>

        ether b8:27:eb:28:f1:db  txqueuelen 1000  (Ethernet)

        RX packets 278  bytes 24526 (23.9 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 162  bytes 23531 (22.9 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 8  bytes 576 (576.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 8  bytes 576 (576.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500

        ether 22:65:72:89:34:45  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi64 ~ # /etc/init.d/NetworkManager stop

 * Stopping NetworkManager ...                                            [ ok ]

pi64 ~ # ifconfig -a

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.115  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::4841:5b11:68e6:b2cb  prefixlen 64  scopeid 0x20<link>

        ether b8:27:eb:28:f1:db  txqueuelen 1000  (Ethernet)

        RX packets 448  bytes 36500 (35.6 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 254  bytes 36363 (35.5 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 8  bytes 576 (576.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 8  bytes 576 (576.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4098<BROADCAST,MULTICAST>  mtu 1500

        ether b8:27:eb:7d:a4:8e  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi64 ~ # ping 8.8.8.8

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=20.4 ms

64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=21.9 ms

^C

--- 8.8.8.8 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 3ms

rtt min/avg/max/mdev = 20.423/21.169/21.916/0.760 ms

pi64 ~ # ping google.lv

PING google.lv (216.58.211.3) 56(84) bytes of data.

64 bytes from muc03s13-in-f3.1e100.net (216.58.211.3): icmp_seq=1 ttl=52 time=20.6 ms

64 bytes from muc03s13-in-f3.1e100.net (216.58.211.3): icmp_seq=2 ttl=52 time=20.0 ms

^C

--- google.lv ping statistics ---

3 packets transmitted, 2 received, 33.3333% packet loss, time 5ms

rtt min/avg/max/mdev = 20.003/20.283/20.563/0.280 ms

pi64 ~ # rc-update del NetworkManager default

 * service NetworkManager removed from runlevel default

pi64 ~ # reboot

```

Now rebooting without NetworkManager in the autostart. Please note that all settings per https://wiki.gentoo.org/wiki/Handbook:X86/Full/Networking#Using_the_old-style_kernel_naming has been already done and was not removed during previous testing!

```
pi64 ~ # ifconfig -a

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.115  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::ba27:ebff:fe28:f1db  prefixlen 64  scopeid 0x20<link>

        ether b8:27:eb:28:f1:db  txqueuelen 1000  (Ethernet)

        RX packets 67  bytes 6108 (5.9 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 51  bytes 8947 (8.7 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 8  bytes 576 (576.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 8  bytes 576 (576.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4098<BROADCAST,MULTICAST>  mtu 1500

        ether b8:27:eb:7d:a4:8e  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi64 ~ # ping 8.8.8.8

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=25.4 ms

64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=19.9 ms

^C

--- 8.8.8.8 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 3ms

rtt min/avg/max/mdev = 19.944/22.689/25.434/2.745 ms

pi64 ~ # ping google.lv

ping: google.lv: Temporary failure in name resolution

pi64 ~ # cd /etc/init.d

pi64 /etc/init.d # ls | grep net.eth0

net.eth0

pi64 /etc/init.d # cat /etc/conf.d/net

#eth0

#config_eth0="dhcp"

config_eth0="192.168.1.115 netmask 255.255.255.0"

routes_eth0="default via 192.168.1.1"

dns_servers_eth0="8.8.8.8 8.8.4.4"

#eth1

#config_eth1="192.168.8.11 netmask 255.255.255.0"

#routes_eth1="default via 192.168.8.1"

#dns_servers_eth1="192.168.8.1 8.8.8.8"

#wlan0

#config_wlan0="dhcp"

pi64 /etc/init.d # /etc/init.d/net.eth0 start

 * WARNING: net.eth0 has already been started

pi64 /etc/init.d # rc-update | grep net.eth0

             net.eth0 |      default

```

----------

## NeddySeagoon

orion777,

```
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.115  netmask 255.255.255.0  broadcast 192.168.1.255 
```

you have an IP address without Network Manager.

How does that happen?

In this state, what is the output of 

```
route
```

What is in /etc/resolv.conf.

You are either missing a route or nameservers ... or both.

Normally, the automatic setup does either everything or nothing.

----------

## orion777

 *NeddySeagoon wrote:*   

> orion777,
> 
> ```
> eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
> 
> ...

 

This IP has been taken from the /etc/conf.d/net file. However, dhcp also assign 192.168.1.115 . To be able to recognize source of the settings, I put IP 192.168.1.200 into the net file.

```
 cat /etc/conf.d/net

#eth0

#config_eth0="dhcp"

config_eth0="192.168.1.200 netmask 255.255.255.0"

routes_eth0="default via 192.168.1.1"

dns_servers_eth0="8.8.8.8 8.8.4.4"

#eth1

#config_eth1="192.168.8.11 netmask 255.255.255.0"

#routes_eth1="default via 192.168.8.1"

#dns_servers_eth1="192.168.8.1 8.8.8.8"

#wlan0

#config_wlan0="dhcp"
```

]

After reboot I have:

```
pi64 ~ # ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.200  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::ba27:ebff:fe28:f1db  prefixlen 64  scopeid 0x20<link>

        ether b8:27:eb:28:f1:db  txqueuelen 1000  (Ethernet)

        RX packets 133  bytes 10534 (10.2 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 80  bytes 12797 (12.4 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 32  bytes 2304 (2.2 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 32  bytes 2304 (2.2 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

```

As can be seen, eth0 takes its configuration from the /etc/conf.d/net as eth0 IP becomes 192.168.1.200

 *Quote:*   

> In this state, what is the output of route?

 

HEre is the output:

```
pi64 ~ # route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

default         192.168.1.1     0.0.0.0         UG    2      0        0 eth0

192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

```

 *Quote:*   

> What is in /etc/resolv.conf ?

 

I was not entering any configurations into it as there are nothing about  /etc/resolv.conf in the https://wiki.gentoo.org/wiki/Handbook:X86/Full/Networking#Using_the_old-style_kernel_naming

So I have no such file in my system:

```
pi64 ~ # cat /etc/resolv.conf

cat: /etc/resolv.conf: No such file or directory

```

--------------------------

Update:

As I plan to run NAT server on this raspberry per https://wiki.gentoo.org/wiki/Ethernet_plus_WiFi_Bridge_Router_and_Firewall the dnsmasq has peen already installed, but it was not configured jet! So, maybe here is the problem cause? 

```
pi64 /etc/hostapd # eix net-dns/dnsmasq

[I] net-dns/dnsmasq

     Available versions:  (~)2.78 (~)2.79{tbz2} {auth-dns conntrack dbus +dhcp dhcp-tools dnssec (+)id idn +inotify ipv6 libidn2 lua nls script selinux static tftp}

     Installed versions:  2.79{tbz2}(08:15:04 24/07/18)(dbus dhcp inotify ipv6 nls -auth-dns -conntrack -dhcp-tools -dnssec -id -idn -libidn2 -lua -script -selinux -static -tftp)

     Homepage:            http://www.thekelleys.org.uk/dnsmasq/doc.html

     Description:         Small forwarding DNS server

pi64 /etc/hostapd # rc-update | grep dnsmasq

pi64 /etc/hostapd # ps -ax | grep dnsmasq

 9672 pts/2    S+     0:00 grep --colour=auto dnsmasq

pi64 /etc/hostapd #

```

----------

## krinn

you lack loopback in boot runlevel?

you should have localhost route define in route too.

you should define your nameserver in /etc/resolv.conf ; and this only for the reason to see if someone is affecting your name servers definition (if you set them in resolv.conf you will see easy if someone alter its content).

----------

## orion777

Since the target was to implement router https://wiki.gentoo.org/wiki/Ethernet_plus_WiFi_Bridge_Router_and_Firewall , i was tune dnsmasq. This enables access to DNS servers both for the LAN and local system itself.

I understand that the use of dnsmasq does not solve problem "tuning system out of the box per https://wiki.gentoo.org/wiki/Handbook:X86/Full/Networking#Using_the_old-style_kernel_naming"

 *Quote:*   

> you lack loopback in boot runlevel? 

  I have no, because there is nothing about it in both instructions, provided above.

----------

