M
M
Mark Chigrin2020-12-11 21:10:12
linux
Mark Chigrin, 2020-12-11 21:10:12

How to start networking without systemd-networkd (networkManager)?

I am doing lab work on networking in linux (ubuntu), but they are outdated, so they suggest disabling the network manager and configuring everything through ifconfig.
Task:
5fd39022c57d2472615233.png
I have ubuntu 20.04 lts in google cloud. And it uses systemd-networkd and the ip command.

I was able to disable networkd and assign ip to the desired interface, but I can’t correctly register route and start a network.

Here are the settings that are set by networkd (I want to repeat them)

[email protected]:~$ ip r

default via 10.166.0.1 dev ens4 proto dhcp src 10.166.0.4 metric 100 
10.166.0.1 dev ens4 proto dhcp scope link src 10.166.0.4 metric 100

[email protected]:~$ ip addr

2: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc mq state UP group default qlen 1000
    link/ether 42:01:0a:a6:00:04 brd ff:ff:ff:ff:ff:ff
    inet 10.166.0.4/32 scope global dynamic ens4
       valid_lft 3585sec preferred_lft 3585sec
    inet6 fe80::4001:aff:fea6:4/64 scope link 
       valid_lft forever preferred_lft forever

I do it like this:
$ sudo ip addr add 10.166.0.4/32 dev ens4
inet 10.166.0.4/32 scope global ens4
       valid_lft forever preferred_lft forever
$ sudo ip route add default via 10.166.0.1
Error: Nexthop has invalid gateway.

i.e. the ip address is added, but the route is not

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
shurshur, 2020-12-11
@Black_and_green

Because the /32 grid consists of a single address 10.166.0.4. The /32 mask is 255.255.255.255. And you need /24 - 255.255.255.0. With her, everything will work as it should.

T
Talyan, 2020-12-11
@flapflapjack

Mark Chigrin , The /24 mask is not required, but it is the most popular.
PPPoE usually works with the 32nd mask, since there communication goes through PADI / PADO, and not through TCP / IP.
If your provider has a gateway and routing through it, then the mask cannot be less than 4 addresses, then bish is like 30.
1 address is the network address, the second is yours, the third is the gateway, the fourth is broadcast.
If you were given your ip, gateway and mask, then:

ip a add addr 25.45.56.23/24 dev ens0s2
ip route add default via 25.45.56.1

where 25.45.56.23/24 is the address and mask given to you, and 25.45.56.1 is the gateway

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question