Biographies Characteristics Analysis

Centos disable ipv6. What to do if the network is not available in CentOS? What to do if CentOS does not see the network card

Starting with EL6, the software vendor decided to remove boot.iso from the /images directory and ship it as a separate independent media. Due to the large size of this image, we decided to do the same. On the this moment The network installation disk image is called netinstall.iso and is located in the isos/ directory along with the rest of the installation images.

2. Why do I need to log in and use it myself in order for my Ethernet network card to work?

And why, when compared with common practice, are the names of network interfaces named "incorrectly"? After all, this violates the Unix rule "don't change expectations".

The software vendor has added NetworkManager to the default configuration, and the network interfaces are (in some inexplicable way) inactive by default. This can be corrected during the installation process at the stage where the installer prompts you to configure the language/keyboard/storage/software in the main installer window, making your network card active. To do this, you need to click "Network & Hostname", select the Ethernet network connection you want to change, and click the "Off" button in the upper right corner. Assuming that you can use DHCP, then your network connection will go into the state of obtaining a network address. If you need to manually configure network settings, click "Configure", then enter and save desired values. In order for the changes to take effect, it will most likely be necessary to disable and then enable the newly configured network interface. Click Done. In addition to the above method, after installation, the network connection can be configured using " NetworkManager" (located in "System; Preferences; Network Connections", or right-click on the small network icon in the notification area, then - "Edit Connections").

If you are not using NetworkManager , then the same result can be achieved by changing the configuration file of the corresponding network interface (usually /etc/sysconfig/network-scripts/ifcfg-eth0): "ONBOOT=no" to "ONBOOT=yes". If you are using DHCP, you may need to add the line "BOOTPROTO=dhcp". A static IP would require "BOOTPROTO=static".

Assuming that the name of the network device is eth0, then changing the ONBOOT line can be done (as root) as follows:

# cd /etc/sysconfig/network-scripts/ # sed -i -e " [email protected]^ONBOOT=" [email protected]="[email protected]"ifcfg-eth0

Regarding "changed expectations": the previous example uses the "traditional" naming of the network interface: eth0. However, other names are also possible, such as em1, p3p1 etc. Like it or not, this naming concept is a further development of Linux. This was described earlier in the "test distribution" of the software vendor. See also Dell's writeup and blog post

3. What if I want to return the old naming?

There are 3 necessary steps for this:

  • add "inet.ifnames=0" and "biosdevname=0" kernel parameters of the grub bootloader;
  • change the config file for your network interface located in /etc/sysconfig/network-scripts/ by renaming it to "ifcfg-ethX";
  • in case you have multiple network interfaces and want to control the naming of each one instead of letting the kernel do it, replace /usr/lib/udev/rules.d/60-net.rules with /etc/ udev/rules.d/60-net.rules

4. But I just need everything to work and to be able to manually change the configuration files

Most installations don't need the undue complexity of interacting with NetworkManager , just manual change configuration files. Below is a snippet of configuring a network interface using DHCP without NetworkManager :

# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO=dhcp NM_CONTROLLED="no" PERSISTENT_DHCLIENT=1 ONBOOT="yes" TYPE=Ethernet DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=yes IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME="eth0" #

or the usual setup using "statics":

$ cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" HWADDR="00:21:70:10:7E:CD" NM_CONTROLLED="no" ONBOOT="yes" BOOTPROTO=static # BOOTPROTO= dhcp IPADDR=10.16.1.106 NETMASK=255.255.255.0 # # the GATEWAY is sometimes in: /etc/sysconfig/network GATEWAY=10.16.1.1

after which you can add other common properties, such as hostname or DNS servers:

$ cat /etc/sysconfig/network HOSTNAME=acme.example.com DNS1=10.16.1.112 DNS2=8.8.8.8 ## DNS2=76.242.0.28 SEARCH=example.com

These parameters are optional because The DHCP server itself can handle them. initscript-s can determine settings such as Computer Name using PTR records in a properly configured DNS environment, but some users may need to manually change the settings. Full documentation on initscripts can be found with:

Rpm -qd initsscripts

even in an environment where there is no man-package and its dependencies.

5. How to disable IPv6?

One of the Software Vendor's employees recommends leaving the IPv6 module enabled, because disabling may affect the operation of SELinux and other components. Instead, it is suggested to add the following lines to /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1

And to disable IPv6 on a running system:

echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6

sysctl -w net.ipv6.conf.all.disable_ipv6=1 sysctl -w net.ipv6.conf.default.disable_ipv6=1

Remark 1: With IPv6 disabled, there may be problems with forwarding X through ssh. To solve this, you need to change /etc/ssh/sshd_config as follows: either change

#AddressFamily any

AddressFamily inet

("inet" matches "ipv4 only", "inet6" matches ipv6)

Or remove the "#" sign before the line

#ListenAddress 0.0.0.0

and restart ssh

Remark 2: If Postfix starts up with IPv6 disabled, then either change /etc/postfix/main.cf - comment out the "localhost" part and replace it with ipv4 loopback:

#inet_interfaces=localhost inet_interfaces=127.0.0.1

or remove the line with ipv6 localhost from the /etc/hosts file.

Remark 3: To disable RPCBIND ipv6 (rpc, rpc.mountd, rpc,statd), comment out the "udp6" and "tcp6" lines in the /etc/netconfig file:

Udp tpi_clts v inet udp - - tcp tpi_cots_ord v inet tcp - - #udp6 tpi_clts v inet6 udp - - #tcp6 tpi_cots_ord v inet6 tcp - - rawip tpi_raw - inet - - - local tpi_cots_ord - loopback - - - unix tpi_cots_ord - loopback - - -

6. Where can I download the 32-bit version?

The 32-bit version of CentOS 7 is located here: http://mirror.centos.org/altarch/7/isos/i386/

7. Where did ifconfig/netstat go?

Because utilities ifconfig and netstat Since the man pages for CentOS-5 and CentOS-6 have been marked as deprecated for over a decade, RedHat has decided not to default the net-tool package to CentOS-7. One reason for this, for example, is that ifconfig does not display all the information on an interface's IP address - use the "ip" command instead. The utilities that came in return are "ss" and "ip". However, if you really need the ifconfig and netstat utilities, you can install the net-tools package: yum install net-tools.

IPv6 or Internet Protocol version 6 is the latest version of Internet Protocol (IP). IPv4 or Internet Protocol version 4 is already being widely used. But it has some limitations. The first one is that IPv4 has a 32-bit address scheme. That means only 4.3 billion unique address is possible with IPv4. That is quite limited in today's world. These days we have many IoT (Internet of Things) devices, smartphones, computers, laptops, servers connected to the internet. Each of these devices need an IP address to communicate to the outside world. So the IPv4 address has a shortage.

IPv6 address in the other hand is a 128-bit address. It means about 340,282,366,920,938,463,463,374,607,431,768,211,456 unique IPV6 address is possible in IPv6. That's a huge number of IP addresses. It is said that if IPv6 is used, every single device in the world can have its own unique IPv6 address and IPv6 would still be available for new devices. So IPv6 solves issues with limited IP address as in IPv4.

But at the time of this writing, IPv6 support is not available in many countries. It's not even supported in my country. Though the world is moving to IPv6 slowly, still not everything is IPv6.

If your country has no support for IPv6 yet, there's no need to keep it enabled on your operating system. So many people tend to disable IPv6 in their operating system.

In this article, I will show you how to disable IPv6 on CentOS 7.5. Let's get started.

Check Whether IPv6 is Enabled

You can check whether IPv6 is enabled on your CentOS 7.5 operating system with the following command:

$ ip a | grep inet6

As you can see, I have IPv6 enabled.

If IPv6 is disabled, you should see no output if you run this command.

Disable IPv6 Using the Kernel Parameter

In this section, I will show you how to disable IPv6 permanently.

You can disable IPv6 when your computer boots by changing the kernel parameter.

First edit the GRUB configuration

$ sudo vim /etc/default/grub

You should see the following window.

First press i to go to INSERT mode.

Now add ipv6.disable=1 before crashkernel=auto in GRUB_CMDLINE_LINUX as marked in the screenshot below.

Now press and type in :wq! and then press to save the file.

Now update the GRUB configuration file with the following command:

$ sudo grub2-mkconfig -o / boot/ grub2/ grub.cfg

The GRUB configuration should be updated.

Now restart your computer with the following command:

$ sudo reboot

If you run the following command again, you should see no output.

$ ip a | grep inet6

Disable IPv6 Using /etc/sysctl.conf Configuration File

You can also disable IPv6 permanently using the /etc/sysctl.conf configuration file.

First open the /etc/sysctl.conf file with the following command:

Now add the following lines to it:

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6 = 1

Now save the file and reboot your computer with the following command:

$ sudo reboot

IPv6 should be disabled.

Disable IPv6 of Specific Network Interface

You can also disable IPv6 of specific network interface.

First you have to find the network interface that you want to disable with the following command:

$ ip link show

You should see the network interface name as marked in the screenshot below.

Let's say you want to disable IPv6 for ens36 interface.

First open /etc/sysctl.conf file with the following command:

$ sudo vim /etc/sysctl.conf

Now add the following line to the end of the file:

net.ipv6.conf.ens36.disable_ipv6=1

Disable IPv6 Temporarily Using sysctl Command

You can also disable IPv6 temporarily. That way IPv6 will be enabled once you reboot your system. This is good for testing whether everything on your CentOS 7.5 operating system works before disabling IPv6 permanently.

Run the following commands to disable IPv6 temporarily:

$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

IPv6 should be disabled.

That's how you disable IPv6 on CentOS 7.5 permanently and temporarily. Thanks for reading this article.

AT this material I will touch hot topic, which starts almost any initial work with the server. Setting up basic network parameters in CentOS - ip address, dhcp, ipv6, dns, hostname, static routes, network cards and other network parameters. We will move on the topic step by step from simple to complex, analyzing all the nuances in order and answering the most popular questions.

Network settings on CentOS 7 server

The first time we encounter the network settings of a CentOS server is when we install. On the initial setup screen, there is a separate item regarding the configuration of network interfaces:

Going into it, we see a list of connected network cards. Each of them can be turned on with the corresponding slider (point 1 in the picture). When the interface is activated, it automatically receives settings via dhcp. You can see the result of dhcp work right there. If you are not satisfied with these settings, you can edit them by clicking configure(item 3 in the picture). Here you can also set hostname(item 2 in the picture):


By opening the additional Ehernet settings window, you can change the name of the network interface, specify the IP settings (item 1 in the picture), select manual settings(item 2 in the picture), assign ip address(item 3 in the picture), install dns server(item 4 in the picture) and save the network settings (item 5 in the picture):


After completing the rest of the settings, the installation will begin. After installation, you will have a server with the network settings you specified.

Now consider another situation. The server, and accordingly the network configuration, was not made by you, but now you need to look at it or change it. The server console is at your disposal, and we will work in it. If you have installed from a distribution minimal, then when you try to view the network settings using the command ifconfig in the console you will see the following:

Bash: ifconfig: command not found

or in the Russian version:

Bash: ifconfig command not found

To work with ifconfig and other network utilities, you need to install the package net-tools. Let's do it:

# yum -y install net-tools.x86_64

Now you can see the network settings:

mtu 1500 inet 192.168.159.129 ether 00:0c:29:7d:59:3f txqueuelen 1000 (Ethernet) RX packets 319 bytes 36709 (35.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 256 bytes 148817 (145.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (Local Loopback) RX packets 6 bytes 624 (624.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 6 bytes 624 (624.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

If you do not want to install an additional package, then you can use a simpler command ip with parameters:

# ip addr 1:lo: mtu 65536 qdisc noqueue state UNKNOWN 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: eno16777728: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:7d:59:3f brd ff:ff:ff:ff:ff:ff inet 192.168.159.129 /24 brd 192.168.159.255 scope global dynamic eno16777728 valid_lft 1709sec preferred_lft 1709sec inet6 fe80::20c:29ff:fe7d:593f/64 scope link valid_lft forever preferred_lft forever

We have seen the network configuration, now let's edit it. Let's say we need to change the ip address. To do this, go to the /etc/sysconfig/network-scripts directory and open the file for editing ifcfg-eth0. This file has the following content:

According to the settings from this file, we get the ip address via dhcp. To manually register a static ip, we bring the file to the following content:

We have changed the settings:

For the changes to take effect, you need to reread the network settings:

Restarting network (via systemctl): [ OK ]

Check if the new network configuration has been applied:

# ifconfig: eno16777728: flags=4163 mtu 1500 inet 192.168.159.129 netmask 255.255.255.0 broadcast 192.168.159.255 inet6 fe80::20c:29ff:fe7d:593f prefixlen 64 scopeid 0x20 ether 00:0c:29:7d:59:3f txqueuelen 1000 (Ethernet) RX packets 672 bytes 71841 (70.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 572 bytes 290861 (284.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Everything is in order, the new network interface settings are set.

How to get network settings via DHCP

Now consider the reverse situation. Let's say your network card has some settings set manually. But you want your computer to receive network settings over dhcp as a client. To do this, you need to perform the operation, the opposite of what we did before. That is, open the /etc/sysconfig/network-scripts/ifcfg-eth0 file and delete the lines with the DNS, IPADDR, PREFIX, GATEWAY parameters there, and specify the value in the BOOTPROTO parameter "dhcp". Save the file and restart the network:

# /etc/init.d/network restart

Then we check if our client received the settings via dhcp.

How to set up DNS on CentOS 7

The current dns server settings in CentOS can be viewed in two places:

  1. In the network card settings file ifcfg-eth0, which we edited several times earlier.
  2. In the file /etc/resolv.conf

Why they are now in two places, I don’t know, but before the dns server settings in some distributions, I don’t remember exactly which ones, they were indicated only in resolv.conf, but at some point this changed. And all network settings began to be stored in one file along with the address, gateway, mask, and so on. If you edit the resolv.conf file now and add some server dns there, then after a reboot they will be replaced with the values ​​from the ifcfg-eth0 file.

So in order to set the dns server parameters, you need to edit the ifcfg-eth0 network settings file, adding as many servers as you need. For example like this:

DNS1="192.168.159.2" DNS2="8.8.8.8" DNS3="8.8.4.4"

To apply the settings, save the file and restart the network, everything is as usual. After restarting the server, the dns settings will be written to the resolv.conf file

# cat /etc/resolv.conf # Generated by NetworkManager nameserver 192.168.159.2 nameserver 8.8.8.8 nameserver 8.8.4.4

How to disable ipv6 on CentOS 7

Protocol currently in active use ipv6 no, it is not needed in normal operation. Although we have been scared for many years that there are practically no free ip addresses left, but in reality there are still enough for everyone. So, for practical reasons, ipv6 is currently not needed on the server and can be disabled.

Before disabling ipv6, just in case, you need to check which programs use it in their work. This is necessary in order to avoid errors in their work by first disabling ipv6 in the configurations. In order to see which programs are hanging on the ipv6 interface, we will use the netstat command:

# netstat -tulnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2317/master tcp 0 0 0.0.0.0 :22 0.0.0.0:* LISTEN 1333/sshd tcp6 0 0::1:25:::* LISTEN 2317/master tcp6 0 0:::22:::* LISTEN 1333/sshd udp 0 0 0.0.0.0:49252 0.0.0.0:* 694/avahi-daemon: r udp 0 0 0.0.0.0:123 0.0.0.0:* 715/chronyd udp 0 0 0.0.0.0:5353 0.0.0.0:* 694/avahi-daemon: r udp 0 0 127.0.0.1:323 0.0.0.0:* 715/chronyd udp6 0 0:::123:::* 715/chronyd udp6 0 0::1:323:::* 715/chronyd

All lines with::: are ipv6 protocol. In my case, these are sshd, postfix and chronyd. Let's disable ipv6 for them and leave only ipv4.

Let's start with sshd. Open the configuration file /etc/ssh/sshd_config and find the lines:

#AddressFamily any #ListenAddress 0.0.0.0

Let's comment them out and change them. It should turn out like this:

AddressFamily inet ListenAddress 0.0.0.0

Now open the postfix configuration file /etc/postfix/main.cf. We are looking for the line there:

#inet_protocols = all

Change to:

inet_protocols=ipv4

Disable ipv6 in chronyd. To do this, create a file /etc/sysconfig/ chronyd and add the line:

OPTIONS=-4

Now disable ipv6 in CentOS. Open file /etc/ sysctl.conf and add the lines there:

net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1

Editing the file /etc/sysconfig/ network by adding there:

NETWORKING_IPV6=no IPV6INIT=no

Reboot and check the result:

# reboot # ifconfig eno16777728: flags=4163 mtu 1500 inet 192.168.159.129 netmask 255.255.255.0 broadcast 192.168.159.255 ether 00:0c:29:7d:59:3f packets 2138 bytes 1327955 (1.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 loop txqueuelen 0 (Local Loopback) 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

There is no mention of inet6 and ipv6 format addresses anywhere. So everything is in order, we have disabled ipv6 in CentOS. Now let's check the list of open ports:

# netstat -tulnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2291/master tcp 0 0 0.0.0.0 :22 0.0.0.0:* LISTEN 1322/sshd udp 0 0 0.0.0.0:123 0.0.0.0:* 2453/chronyd udp 0 0 0.0.0.0:5353 0.0.0.0:* 697/avahi-daemon: r udp 0 0 127.0.0.1:323 0.0.0.0:* 2453/chronyd udp 0 0 0.0.0.0:57259 0.0.0.0:* 697/avahi-daemon: r

All ipv4 ports. All right, our task is done.

How to change hostname in CentOS 7

By default, during CentOS installations puts the hostname localhost.localdomain. If you haven't changed it, you can do it later. First, let's check what hostname you have set. This is done using the command in the console hostname, or using uname:

# hostname localhost.localdomain # uname -n localhost.localdomain

In order to change the hostname in CentOS, you need to edit the file /etc/hostname. Let's check its contents:

# cat /etc/hostname localhost.localdomain

Let's edit this file to change the hostname:

# mcedit /etc/hostname centos.localhost

Save the file and check:

# hostname centos.localhost

There is a ready-made command that immediately sets the required server name:

# hostnamectl set-hostname centos.localhost

All right, we have changed the hostname to centos.localhost

Set Default Gateway on CentOS 7

If for some reason, when configuring the network settings, you did not set the default gateway, then you can do it manually. First, let's check which default gateway is installed in the system in this moment:

# netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 149.154.71.254 0.0.0.0 UG 0 0 0 eth0 10.8.0.0 10.8.0.2 255.255.255.0 UG 0 0 Tun0 10.8.0.2 0.0.0.0.0 255.255.255.255 UH 0 0 Tun0 149.154.70.0 0.0.0.25.255.254.0 U 0 0 ETH0 192.168.1.0 10.8.0.2 255.255. 255.0 UG 0 0 0 tun0

The line with Destination 0.0.0.0 specifies the gateway address. If you do not have it, or the wrong gateway is set in the Gateway field, then you can change it. Set the default gateway:

route add default gw 192.168.0.1

Network Manager on CentOS 7

By default, CentOS has a service that manages all network connections - network manager. It constantly monitors network settings and uses the configuration management daemon to make appropriate changes to active network devices. It supports standard ifcfg configuration files.

List of network utilities and applications:

Users do not interact directly with NetworkManager on CentOS, but use graphical and command line utilities. One of these utilities is system config network tui.

System config network tui on CentOS 7

To manage network settings in CentOS, you can use a graphical utility nmtui. Checking its presence in the system is very simple. It is enough to run it in the console:

If you do not have it installed, then fixing it is very simple. Install in CentOS system config network tui:

# yum install NetworkManager-tui

Via tui you can specify any network settings that we did before through the command line and editing configuration files. Let's do that. We call the program:

Choose the first item Edit a connection, then select the network interface and click "Edit":

Here we can change the name of the network card, mac address, specify the type of network settings - manual or dhcp, manually specify the ip address, gateway address, dns server, add routes and some other settings:


After finishing editing, save the settings by clicking OK.
If you select the item in the first screen of the utility Set System Hostname, you can quickly specify the hostname. The result will be the same as we did before in the console.

How to add a static route in CentOS 7

You may need to add a static route to control routing on CentOS. This is easy enough to do with a console command. First, let's check the existing routes using netstat:

# netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.159.2 0.0.0.0 UG 0 0 0 eno16777728 192.168.159.0 0.0.0.0 255.255.255.0 U 0 0 0 eno1677

In this case, we have one route for the address 0.0.0.0/0.0.0.0, the gateway is 192.168.159.2, which is also the default gateway. That is, in fact, there are no static routes. Let's add one of them.

Let's say we have a subnet 192.168.8.0 mask 255.255.255.0, traffic to this subnet is routed by the gateway 192.168.159.5 Add a route:

# route add -net 192.168.8.0/24 gw 192.168.159.5

Check if the added route has appeared in routing table:

# netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.159.2 0.0.0.0 UG 0 0 0 eno16777728 192.168.8.0 192.168.159.5 255.255.255.0 UG 0 0 0 eno16777728 192.168.159.0 0.0.0.0 255.255.255.0 U 0 0 0 eno16777728

All right, the route has been added. But after a reboot, this static route will be removed. To prevent this from happening and to save the added routes, you need to write them to a special file. In the /etc/sysconfig/network-scripts folder, create a file named route-eth0 the following content:

# mcedit /etc/sysconfig/network-scripts/route-eth0 192.168.8.0/24 via 192.168.159.5

Reboot and check if the route is in place:

# reboot # netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.159.2 0.0.0.0 UG 0 0 0 eno16777728 192.168.8.0 192.168.159.5 255.255.255.0 UG 0 0 0 eno16777728 192.168.159.0 0.0 .0.0 255.255.255.0 U 0 0 0 eno16777728

All right, the static route has been added.

How to configure 2 IP addresses on one interface

If you need to set up 2 IP addresses on the same interface in CentOS, then this is quite simple. Let's use the ifconfig command. First, let's check the list of network interfaces:

# ifconfig eno16777728: flags=4163 mtu 1500 inet 192.168.159.129 netmask 255.255.255.0 broadcast 192.168.159.255 ether 00:0c:29:7d:59:3f packets 204 bytes 27658 (27.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73

Let's add one more ip address 192.168.159.120 to the eno16777728 interface:

# ifconfig eno16777728:1 192.168.159.120 up

Let's check what happened:

# ifconfig eno16777728: flags=4163 mtu 1500 inet 192.168.159.129 netmask 255.255.255.0 broadcast 192.168.159.255 ether 00:0c:29:7d:59:3f packets 204 bytes 27658 (27.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eno16777728:1: flags=4163 mtu 1500 inet 192.168.159.120 netmask 255.255.255.0 broadcast 192.168.159.255 ether 00:0c:29:7d:59:3f txqueuelen 1000 (Ethernet) lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 loop txqueuelen 0 (Local Loopback) RX packets 11 bytes 940 (940.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 11 bytes 940 (940.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

All right, we added a second ip address to the same interface. But after the reboot, the additional address will not be saved. To save it, you need to create an interface settings file in the /etc/sysconfig/network-scripts folder

# mcedit /etc/sysconfig/network-scripts/ ifcfg-eno16777728:1 DEVICE=eno16777728:1 BOOTPROTO=static IPADDR=192.168.159.120 NETMASK=255.255.255.0 ONBOOT=yes

Save the file, reboot and check what happened. The second ip address must be in place.

How to do network restart in CentOS 7

I have already touched on this issue before, but just in case, we will repeat it separately. Let's say you made some changes to your network configuration. How can I apply these settings without restarting the server? Very simple. To restart the network in CentOS, just use the command:

# /etc/init.d/network restart

The NetworkManager service will reread all network settings and apply the changes.

How to find IP address in CentOS 7

In order to quickly find out the current IP address in CentOS, you need to use the following commands:

# ifconfig | grep inet inet 192.168.159.129 netmask 255.255.255.0 broadcast 192.168.159.255 inet 127.0.0.1 netmask 255.0.0.0

Or the second option for determining the local ip address:

# ip addr | grep inet inet 127.0.0.1/8 scope host lo inet 192.168.159.129 /24 brd 192.168.159.255 scope global eno16777728

Both commands allow you to quickly find out your ip address.

What to do if CentOS does not see the network card?

You installed the server, booted up and found that there is not a single network card in the system. What to do in this case? First of all, look at the output of the dmesg command and look for a reminder of your card there. Perhaps it is in the system, it's just not activated. You can activate it with nmtui, which I mentioned above.

There is a menu item Activate connection, you need to go into it and activate your network card. After that, it can be configured.

If your network card is not in the system, then you need to search the Internet for information about this network card by model. Perhaps there will be drivers for it in the repositories. This is a fairly common situation. Most often, drivers will be found and they will need to be installed correctly.

There's also a chance that you won't see your card when you run the ifconfig command unless a network wire is plugged into that card. To see all interfaces for sure, you need to use the -a switch:

# ifconfig -a

There is another way to look for a network card in the system. Install the package pciutils:

# yum -y install pciutils

And see the output of the command:

# lspci | grep ethernet

If the network card is seen by the system, then there should be something like this:

02:00.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)

If the output is empty, then the network card is not defined.

What to do if the network is not available in CentOS?

Let's say you try to ping some address, for example 8.8.8.8, and get a response that the network is not available:

# ping 8.8.8.8

And in response you get:

Connect: Network is unreachable

This situation may occur if you do not have a default gateway installed. You can add it with the command:

# route add default gw 192.168.0.1

If it's not the gateway, then you need to check the network adapter settings. If there is no active adapter, then you will also receive a message that the network is down. You must have at least one network adapter configured correctly on your system. How to do this is written above.

Using traceroute, dig network utilities on CentOS

To diagnose network connections in CentOS, it is useful to use special utilities. But if you used the minimal installation, then most likely they will not be in the system. For example, the popular utility traceroute when you try to run it, it will display the following message:

# traceroute ya.ru bash: traceroute: command not found

It needs to be installed separately from the repository:

# yum -y install traceroute

The same with the popular program dig to work with dns servers and records:

# dig ya.ru bash: dig: command not found

To this network utility earned, you need to install the package bind-utils:

# yum -y install bind-utils

Configuring 802.1Q VLANs on CentOS 7

To raise a tagged interface on CentOS, you must first check for kernel support 8021q:

# modprobe 8021q

If there are no error messages, then everything is in order, the module has loaded. If the module is not found, the kernel modules must be rebuilt to include support for the required module. Just in case, let's check if the module has loaded:

# lsmod | grep 8021q 8021q 29022 0 garp 14384 1 8021q mrp 18542 1 8021q

Everything is in order, the 8021q module is loaded, let's add it to autoload:

# echo 8021q >> /etc/modules-load.d/8021q.conf

Now we create a configuration file for vlan in /etc/sysconfig/network-scripts:

#mcedit ifcfg-eth0.2000 VLAN=yes DEVICE=eth0.2000 BOOTPROTO=static ONBOOT=yes TYPE=Vlan IPADDR=192.168.100.2 NETMASK=255.255.255.0

I draw your attention to the bold. In all the instructions on the Internet that I came across, this parameter was indicated as TYPE=Ethernet, but with this setting, the interface with vlan did not rise, an error appeared:

Error: no device found for connection "System eth0.2000".

Only after I fixed it, everything worked as it should. So save and activate the interface:

# ifup eth0.2000 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)

Checking our vlan:

# ip l ls 1:lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 00:15:5d:01:0f:06 brd ff:ff:ff:ff:ff:ff 3: [email protected]: mtu 1500 qdisc noqueue state UP mode DEFAULT link/ether 00:15:5d:01:0f:06 brd ff:ff:ff:ff:ff:ff

Everything is in order, the tagged interface is up. By analogy, you can create several more similar interfaces, remembering to change their names and addresses.

This concludes my voluminous material on the topic of setting up a network in CentOS. I will be very glad to comments, remarks, amendments. They certainly will. By creating such materials, I first of all learn myself and improve my knowledge in the subject area. There may be errors and omissions somewhere, although I check everything on live systems while writing manuals, inaccuracies and typos are still possible.

Online course "Linux Administrator"

If you have a desire to learn how to build and maintain highly available and reliable systems, I recommend getting acquainted with online course "Linux Administrator" in OTUS. The course is not for beginners, for admission you need basic knowledge of networks and installing Linux on a virtual machine. The training lasts 5 months, after which successful graduates of the course will be able to be interviewed by partners. Test yourself on the entrance test and see the program in more detail.

As you know, the IPv6 protocol appeared as an alternative to the IPv4 protocol, since it allows the use of more addresses than its predecessor. However, the transition from IPv4 to IPv6 continues to this day, and IPv6 support is not universally present. Support for IPv6 requires support for both the operating system and the network infrastructure as a whole. For this reason, if this protocol is not supported on your server, then it is better to disable it so that the network works with functioning protocols. When IPv6 is enabled but not working, there may be delays associated with routing, for example, when searching for a domain, trying to connect to IPv6 addresses, and the problem may also appear in various programs using network connections.
Let's look at several ways to disable IPv6 in Linux CentOS 7. For these purposes, we need access to the server console with superuser rights.

Method one
We disable the IPv6 protocol for all interfaces of the operating system, for this we need to make changes to the /etc/sysctl.conf file. Open the file in built-in:

Vi /etc/sysctl.conf

Add the following lines:

net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1

It may also be necessary to disable the IPv6 protocol for individual interfaces, suppose the interface name is enp0s3, in this case add the following line:

net.ipv6.conf.enp0s3.disable_ipv6=1

We save the changes in the file, and then apply the changes in the configuration:

Sysctl -p

Method two
If you need to disable IPv6 without restarting the configuration, you can use the commands below to make changes on the fly.

echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6

Enter the commands one by one, one by one, you can also use the following commands:

Sysctl -w net.ipv6.conf.all.disable_ipv6=1

After executing these commands, IPv6 will be disabled. In addition, after disabling IPv6, problems may appear with some programs, where you should also indicate that they do not try to use IPv6. More on this later.

SSH issues after disabling IPv6
If you have problems with SSH after disabling IPv6, follow these steps. Open the configuration file /etc/ssh/sshd_config

Vi /etc/ssh/sshd_config

Find the line:

#AddressFamily any

Let's look like this:

AddressFamily inet

Or you can uncomment (remove the # symbol at the beginning) the line:

systemctl restart sshd

Issues with Posfix after disabling IPv6
Problems can also appear with Postfix after disabling IPv6, to correct the situation, you must perform the following steps.
Opening the configuration file /etc/postfix/main.cf:

/etc/postfix/main.cf

Finding a string inet_interfaces with meaning localhost and comment it out, leaving only the line with the value 127.0.0.1.

#inet_interfaces=localhost inet_interfaces=127.0.0.1 systemctl restart postfix

If you have the opportunity to use IPv6, you can return the settings to their original positions in the same way, it will not be difficult. After disabling non-functioning IPv6, you may notice an improvement in network performance.

Post describes procedure to disable IPv6 on CentOS/RHEL 7. There are 2 ways to do this:
1. Disable IPv6 in kernel module (requires reboot)
2. Disable IPv6 using sysctl settings (no reboot required)

To verify if IPv6 is enabled or not, execute:

# ifconfig -a | grep inet6 inet6 fe80::211:aff:fe6a:9de4 prefixlen 64 scopeid 0x20 inet6::1 prefixlen 128 scopeid 0x10

1. Disable IPv6 in kernel module (requires reboot)

1. Edit /etc/default/grub and add ipv6.disable=1 in line GRUB_CMDLINE_LINUX, e.g.:

# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto rhgb quiet" GRUB_DISABLE_RECOVERY="true"

2. Regenerate a GRUB configuration file and overwrite existing one:

# grub2-mkconfig -o /boot/grub2/grub.cfg

3. Restart system and verify no line "inet6" in "ip addr show" command output.

# shutdown -r now

# ip addr show | grep net6

2. Disable IPv6 using sysctl settings (no reboot required)

1. Append below lines in /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1

2. To make the settings affective, execute.