Network Related Info, Commands, Etc
Network Related Info, Commands, Etc
Network Related Info, Commands, Etc
av@Hamsathwani:~$ date
Friday 04 February 2022 11:31:08 PM IST
###################
Internet was too slow (ACT Fibernet – using Ethernet LAN Cable):
av@Hamsathwani:~$ date
Friday 18 February 2022 10:50:46 PM IST
Uncommented the highlighted (red) line in the file below and saved.
Source: https://askubuntu.com/questions/1230525/ubuntu-20-04-network-performance-extremely-slow
#
# scopev4 <mask> <value>
# Add another rule to the RFC 6724 scope table for IPv4 addresses.
# By default the scope IDs described in section 3.2 in RFC 6724 are
# used. Changing these defaults should hardly ever be necessary.
# The defaults are equivalent to:
#
#scopev4 ::ffff:169.254.0.0/112 2
#scopev4 ::ffff:127.0.0.0/104 2
#scopev4 ::ffff:0.0.0.0/96 14
Since the wifi power management was disabled (as seen above) nothing was done.
#!/bin/bash
change_mac(){
# Prevent enless loop on error
if (( COUNT >= 10 )); then exit 0; else COUNT=$(( COUNT + 1 )); echo "Attempt: $COUNT"; fi
# Generate a new MAC address
MAC="$(echo $RANDOM | md5sum | head -c 17 | sed -r 's/(..)./\1:/g')"
# Change the MAC address of the target network interface
/sbin/ifconfig "$1" hw ether "${MAC}"
# Chech whether the MAC is successfully changed anf if is not call the function again
if [ $? -ne 0 ]; then change_mac; fi
# Log the change
echo "Interface: $1 | MAC: $MAC"
}
# Call of the function; Change 'enp0s25' with the actual interface in use; Create a log file
`/tmp/mac-changer-...`
change_mac 'enp0s25' > /tmp/mac-changer-enp0s25 2>&1
Verify if the above script is working.
Listening on LPF/enp5s0/5c:f9:dd:3e:78:5b
Sending on LPF/enp5s0/5c:f9:dd:3e:78:5b
Sending on Socket/fallback
DHCPRELEASE of 192.168.0.33 on enp5s0 to 192.168.0.1 port 67 (xid=0x50031766)
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
av@Hamsathwani:~$ ls /sys/class/net/
enp5s0 lo
av@Hamsathwani:~$ ifconfig
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 2568 bytes 274631 (274.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2568 bytes 274631 (274.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
av@Hamsathwani:~$ nmcli device show
GENERAL.DEVICE: enp5s0
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 5C:F9:DD:3E:78:5B
GENERAL.MTU: 1500
GENERAL.STATE: 10 (unmanaged)
GENERAL.CONNECTION: --
GENERAL.CON-PATH: --
WIRED-PROPERTIES.CARRIER: off
IP4.GATEWAY: --
IP6.GATEWAY: --
GENERAL.DEVICE: lo
GENERAL.TYPE: loopback
GENERAL.HWADDR: 00:00:00:00:00:00
GENERAL.MTU: 65536
GENERAL.STATE: 10 (unmanaged)
GENERAL.CONNECTION: --
GENERAL.CON-PATH: --
IP4.ADDRESS[1]: 127.0.0.1/8
IP4.GATEWAY: --
IP6.ADDRESS[1]: ::1/128
IP6.GATEWAY: --
IP6.ROUTE[1]: dst = ::1/128, nh = ::, mt = 256
The device name : assigned by udev when the device was plugged to your computer (eth0 in this case);
Your device MAC address, referred here as the hardware address;
The device state : whether it is connected to the network or not;
The IPv4 address using a CIDR notation (192.168.1.16/24)
The IPv4 of your subnet gateway (192.168.1.1);
The IPv4 of your main DNS (192.168.1.1)
Note : here, the gateway is acting as the main DNS but you might have dedicated name servers in your company.
Those characteristics are quite useful if you want to list network cards available on your host and determine whether
they are connect or not.
Note that ifup and ifdown are only used to set up interfaces listed in /etc/network/interfaces. If a network interface
(for ex., enp5s0) is not described in this file, these commands won’t know what to do. So, first you need to configure
the details in the /etc/network/interfaces file. For ex.,
[ifupdown]
managed=false
[device]
wifi.scan-rand-mac-address=no
Since it is configured as managed=false in the file, the network connection is managed by the NetworkManager ONLY
using the /etc/NetworkManager/NetworkManager.conf configuration & not using the /etc/network/interfaces
configuration file. So, any configuration in /etc/network/interfaces file will not have any effect (unless you use the
nmcli connection up <uuid> command, where uuid is the unique device id shown when you use nmcli conn sh
command.
Note: nmcli connection up <<uuid> command switches ON the networking - despite the config file used.
Alternatively, sudo ifup <device name> also brings the networking up (provided the network interface/device is
configured in the /etc/network/interfaces file).
Since we used the sudo ifdown enp5s0 command above, the connection went down.
Below steps show how to bring the connection back using NetworkManager.
Listening on LPF/enp5s0/5c:f9:dd:3e:78:5b
Sending on LPF/enp5s0/5c:f9:dd:3e:78:5b
Sending on Socket/fallback
DHCPDISCOVER on enp5s0 to 255.255.255.255 port 67 interval 3 (xid=0x1a86ef71)
DHCPOFFER of 192.168.0.33 from 192.168.0.1
DHCPREQUEST for 192.168.0.33 on enp5s0 to 255.255.255.255 port 67 (xid=0x71ef861a)
DHCPACK of 192.168.0.33 from 192.168.0.1 (xid=0x1a86ef71)
bound to 192.168.0.33 -- renewal in 39061 seconds.
The above command brings up the Network connection with the Ethernet device enp5s0, whose MAC address is
5c:f9:dd:3e:78:5b.
GENERAL.DEVICE: lo
GENERAL.TYPE: loopback
GENERAL.HWADDR: 00:00:00:00:00:00
GENERAL.MTU: 65536
GENERAL.STATE: 10 (unmanaged)
GENERAL.CONNECTION: --
GENERAL.CON-PATH: --
IP4.ADDRESS[1]: 127.0.0.1/8
IP4.GATEWAY: --
IP6.ADDRESS[1]: ::1/128
IP6.GATEWAY: --
IP6.ROUTE[1]: dst = ::1/128, nh = ::, mt = 256
Note: Note the difference in the output of the same command nmcli device show above and here. The first time we
used this command after running sudo ifdown enp5s0 command; hence, we get an output which didn’t show any
details on ip address (as the ifdown command had brought the connection down). However, since we used the sudo
ifup enp5s0 this time, it shows the complete connection details (as the ifup command has brought the network up,
now).
Similarly, notice the difference in the output of the below commands also.
Now the ip link show command says that the enp5s0 network interface state is UP; and, the ifconfig command
shows the output for enp5s0 also (with both ipv4 and ipv6 addresses). Also, unlike earlier, the hostname -I command
returns the ip address now.
1. cat /proc/net/dev
2. ls /sys/class/net
3. ip link show
4. ifconfig
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
av@Hamsathwani:~$ ls /sys/class/net
enp5s0 lo
av@Hamsathwani:~$ ifconfig
enp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.33 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::5ef9:ddff:fe3e:785b prefixlen 64 scopeid 0x20<link>
ether 5c:f9:dd:3e:78:5b txqueuelen 1000 (Ethernet)
RX packets 86385 bytes 68229585 (68.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 54833 bytes 12809606 (12.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 1 collisions 0
av@Hamsathwani:~$ hostname -I
192.168.0.33
See link below to know how to switch to /etc/network/interfaces to control/manage network connections.
https://linuxconfig.org/how-to-switch-back-networking-to-etc-network-interfaces-on-ubuntu-20-04-focal-fossa-linux
Netplan is a utility for easily configuring networking on a Linux-based system. It supports both networkd and
NetworkManager. networkd is part of Systemd. In other word systemd-networkd used to manage network
connections using Systemd. On the other hand NetworkManager is a GUI tool for configuring networking options.
You can tell Netplan to use NetworkManager and it is useful for Linux desktop or laptop users. By default all network
devices get handled by systemd-networkd.
NetworkManager vs networkd:
Source: https://askubuntu.com/questions/1122757/netplan-vs-networkmanager-on-ubuntu-18-04-and-above
The difference the renderer makes, is the decision to run either systemd-networkd or NetworkManager. This
distinction is identified by a file in /etc/netplan/*.yaml.
networkd is normally used in server installations, where the network environment is fairly static.
NetworkManager is normally used in desktop installations, and was used in all prior versions of Ubuntu.
NetworkManager is easier to use in environments where network requirements change a lot... like in wireless
networking. nmcli/nmtui/etc are NetworkManager commands.
Good reference on networkd:
https://wiki.archlinux.org/title/Systemd-networkd
Link 2 (enp5s0)
Current Scopes: none
DefaultRoute setting: no
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
Step-1:
Sample outputs:
Change the value of renderer: to networkd or NetworkManager, as you wish – to switch between the two.
Again, change the value of renderer: to networkd or NetworkManager, as you wish – to switch between the two.
Note: Make sure, however, that these 2 files’ configuration match always.
Finally, ensure that the NetworkManager is managing the nework. The NetworkManager.conf file should look something
like this.
[ifupdown]
managed=false
[device]
wifi.scan-rand-mac-address=no
This managed=false means network-manager will not manage network interfaces defined in
/etc/network/interfaces.
Note also that the NetworkManager is using the plugin: ifupdown (thus, ifup and ifdown commands) to manage the
networks.
Addl. Info:
Source: https://askubuntu.com/questions/653674/is-the-file-etc-network-interfaces-ignored-when-i-use-the-
network-manager
By default ifup/ifdown configures network interfaces based on interface definitions from /etc/network/interface
file.
network-manager can read and configure interfaces reading this file, using a plugin named ifupdown.
You might see a line like in /etc/NetworkManager/NetworkManager.conf file's main configuration snippet :
plugins=ifupdown,keyfile,ofono
[ifupdown]
managed=false
This managed=false means network-manager will not manage network interfaces defined in
/etc/network/interfaces.
To solve your problem you need to make it true so that the /etc/network/interfaces file is parsed by network-
manager and hence the relevant interface(s) will be configured accordingly :
[ifupdown]
managed=true
On a different note, if you have interface(s) defined in /etc/network/interfaces and not using network-manager
for any other interfaces then you should better consider these two options :
Let ifup/ifdown manages the interface(s) (you can uninstall network-manager if you want in this case)
Network Manager strives for Network Connectivity, which “Just Works” for new Linux users. The machine should use
the wired network connection when it’s plugged in but automatically switch to a wireless connection when the user
unplugs it. Similarly, you can easily configure a VPN network and many other options. Edit the config file using a text
editor such as nano command or vim command.
Note: This step is only required if you have multiple .yaml files in the path. If you have only this file:
/etc/netplan/01-network-manager-all.yaml in the path, then, directly create the 01-netcfg.yaml file. This step
is not required.
In fact, you can delete existing netplan config file 01-netcfg.yaml (if any) & use the below command to auto-
generate it. Then, modify the contents as required. Usually the auto-generated file creates only the renderer config.
Update it as follows:
Note: Proper indentation is a must for .yaml files & tabs are not allowed (only spaces are allowed).
Note: The above configuration is for NetworkManager as the renderer (i.e. network will be managed by
NetworkManager. If you want networkd to manage the network connections, use the commented line, instead.
Note: Similarly, the above config shows only the configuration for Ethernet connections. For wifi connections, you
need to add the wifi part too (commented in the above file).
Save and close the file. You can reboot the Linux computer or apply change by typing the following command:
The above command applies the current netplan configuration to a running system.
Step-3: How do I use a GUI tool to configure networking?
Now you can edit or and set new IP address. Select IPv4 or IPv6. Type in the IP Address and Gateway, as well as the
appropriate Netmask. In the DNS section, switch the Automatic switch to off. Enter the IP address of a custom DNS
server (i.e. changing the default DNS Server) you want to use and so on:
####################
Note: Installed speedtest and traceroute (see File: System Config & System Commands Exec History (starting Feb 19,
2022).docx). Installed traceroute in order to troubleshoot(trace the packet route), as speedtest was giving errors.
Connection used: ACT Fibernet (75MBps)
The Network Interface was configured both in /etc/network/interfaces file, and netplan was also installed (as seen
below). May be, this is the issue.
av@Hamsathwani:~$ date
Sunday 20 February 2022 10:44:20 AM IST
Note: Uninstalled ifupdown utility to see if the network still works only with nmcli utility. Found that it is workng
fine. So, either ifupdown or nmcli commands can be used to start/stop/manage the network related stuff.
av@Hamsathwani:~$ date
Sunday 20 February 2022 10:44:20 AM IST
#################
please try this commands out and see if the problem fixed.
please use this two commands for networking status and post it on comments:
#############
###############
Need to check if there are any implications or side-effects (as the destination address was of ACT Fibernet’s Nokia
Router’s).
Source: https://askubuntu.com/questions/278964/what-could-be-the-cause-for-these-strange-ufw-block-entries-in-
my-syslog
https://unix.stackexchange.com/questions/71613/how-can-i-disable-ufw-logging-for-a-specific-event
https://www.searchnetworking.de/forum/messages.cfm?threadid=39135782-2F85-4EC9-9FE07BF91E077A69 (Didn’t
open it, due to security risk warning).
ufw supports per rule logging. By default, no logging is performed when a packet matches a rule.
All you have to do is create a UFW deny rule to match those multicast packets.
sudo ufw deny from 192.168.178.1 to 224.0.0.1
ams@hamsathwani:~$ date
Friday 25 March 2022 07:21:44 PM IST
################