For Cloud Servers, VPS, Virtual Server Cloud, Dedicated Servers and Server Power Deals managed in the Cloud Panel as well as Server Power Deals and Value Dedicated Servers managed in the server administration of the IONOS account

This article lists the most important commands you need to check the network configuration.

Performing a Port Scan

To perform a port scan, you can use the netcat program. Netcat (nc), is a universal command line tool. It can be used in the terminal or in scripts for communication via TCP and UDP network connections (Internet Protocol Version 4 and Version 6).

The program netcat is part of every Ubuntu installation, but can be installed using the following commands, if necessary:

Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04

[root@localhost ~]# apt-get update
[root@localhost ~]# apt-get install netcat

To install netcat on a server with the distribution CentOS, enter the following command:

CentOS 7, CentOS Stream 8 and 9

[root@localhost ~]# yum update
[root@localhost ~]# yum install -y nc

To perform a port scan with netcat, type the following command:

nc -v IP_ADDRESS_OF_THE_SERVER PORT_NUMBER

Example:

[root@localhost ~]# nc -v 192.168.1.1 22

Checking the Network Services

To get a list of listening network services, daemons, and programs, type the following command:

netstat –tulpen

If netstat is not installed, you can install it using the following command:

CentOS 7, CentOS Stream 8 and 9

[root@localhost ~]# sudo yum install net-tools

Ubuntu

[root@localhost ~]# sudo apt-get install net-tools


Then you can check if the relevant network services, daemons and programs are active and listening on the correct port. After entering the command, you can also determine whether the required port needs to be unblocked.

Example:

[root@localhost ~]# netstat -tulpen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      193        27635      1368/systemd-resolv
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          29477      1582/sshd
tcp6       0      0 :::5355                 :::*                    LISTEN      193        27638      1368/systemd-resolv
tcp6       0      0 :::22                   :::*                    LISTEN      0          29479      1582/sshd
udp        0      0 0.0.0.0:5355            0.0.0.0:*                           193        27634      1368/systemd-resolv
udp        0      0 127.0.0.53:53           0.0.0.0:*                           193        27640      1368/systemd-resolv
udp        0      0 0.0.0.0:68              0.0.0.0:*                           0          27510      1314/dhclient
udp        0      0 127.0.0.1:323           0.0.0.0:*                           0          25505      1174/chronyd
udp6       0      0 :::5355                 :::*                                193        27637      1368/systemd-resolv
udp6       0      0 ::1:323                 :::*                                0          25506      1174/chronyd

Checking the Network Configuration

To display the configured interfaces, enter the command ip addr. After entering the command, the status of each interface is displayed:

Example:

root@localhost:~# ip addr
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: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:50:56:00:f1:5b brd ff:ff:ff:ff:ff:ff
    inet 217.160.173.123/32 brd 217.160.173.123 scope global ens192
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe00:f15b/64 scope link
       valid_lft forever preferred_lft forever


You can reactivate a deactivated interface with the following command:

Ubuntu 22.04, CentOS Stream 8, CentOS Stream 9:

root@localhost:~#  sudo ip link set NAME_OF_THE_INTERFACE up

Example:

root@localhost:~# sudo ip link set ens192 up

Ubuntu 20.04, CentOS 7

sudo ifup NAME_OF_THE_INTERFACE

 

Example:

[root@localhost ~]# sudo ifup ens192

If this command fails, it is possible that the interface is in a state unknown to the command script. In this case, enter the same command with the --force parameter:

sudo ifup --force NAME_OF_THE_INTERFACE

Example:

[root@localhost ~]# sudo ifup --force ens192

Then check, if you can establish an encrypted network connection to your server. If this is not possible, check the network configuration of the server.

For this purpose, open the configuration files listed below with the vi editor. Check and edit the settings and then restart the network if necessary to apply the changes to the network configuration:

Ubuntu 18.04, Ubuntu 20.04

/etc/network/interfaces


Ubuntu 22.04

/etc/netplan


CentOS 7

/etc/sysconfig/network-scripts/


CentOS Stream 8 

/etc/sysconfig/network-scripts/ifcfg-ens192


CentOS Stream 9

/etc/NetworkManager/system-connections/ens192.nmconnection


To reboot the network, enter the following command(s):

Ubuntu 18.04, Ubuntu 20.04

[root@localhost ~]# /etc/init.d/networking restart 

Ubuntu 22.04

If you are using Ubuntu 22.04, reboot the server. To do this, enter the following command:

[root@localhost ~]# systemctl reboot

CentOS 7

[root@localhost ~]# /etc/init.d/network restart

CentOS Stream 8 and CentOS Stream 9

If you are using CentOS Stream 8 or CentOS Stream 9, reboot the server. To do this, enter the following command:

[root@localhost ~]# systemctl reboot

Display and Configure IP Routing Table With Route

With the program route you can display and configure the IP routing table. To do so, enter the following command:

[root@localhost ~]# route

After entering the command, you will see results similar to the following example:

[root@localhost home]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 ens192
gateway         0.0.0.0         255.255.255.255 UH    100    0        0 ens192
169.254.169.254 gateway         255.255.255.255 UGH   100    0        0 ens192
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
localhost       0.0.0.0         255.255.255.255 UH    100    0        0 ens192