Centos8 server configures the pits stepped by internal and external networks

Using server DEll R440

1, Server network troubleshooting:

1. One end of the network cable is directly connected to the school router, and the other end is connected to its own notebook
2. Being able to access the Internet means that there is no problem with the router port and network cable
2.1. The Intranet can be accessed, but the extranet cannot
2.2 check whether the indicator light of the network port flashes (generally: green light on + green light flashing, yellow light on + green light flashing)
2.3 if the indicator light is not on or flashing, there is a problem with the network cable or server network card
3. All the above are normal (gateway or route conflict)

1. There is a problem: ping cannot access the Internet

[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (220.181.38.149) 56(84) bytes of data.
From localhost.localdomain (192.168.120.2) icmp_seq=1 Destination Host Unreachable
From localhost.localdomain (192.168.120.2) icmp_seq=12 Destination Host Unreachable
From localhost.localdomain (192.168.120.2) icmp_seq=13 Destination Host Unreachable

2. Troubleshooting:

ping Internet IP
ping Internet Gateway
All can be ping ed, indicating that the external network is good (it may be a server routing or gateway conflict)

Solution 1: (it can be accessed, but the restart is invalid)

1. View gateway status:

[root@localhost network-scripts]# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg-eno*
/etc/sysconfig/network-scripts/ifcfg-eno1:#GATEWAY=192.168.130.1 notes of Intranet gateway
/etc/sysconfig/network-scripts/ifcfg-eno2:GATEWAY=192.168.10.2               Internet Gateway open

2. Add configuration file

[root@localhost etc]# vim resolv.conf 
# Generated by NetworkManager
nameserver 192.168.10.1            Internet Gateway
nameserver 192.168.130.1          Intranet gateway

3. Add the default route and configure the gateway of "extranet"

route add default gw Internet Gateway ip dev Network card name
[root@localhost network-scripts]# route add default gw 192.168.10.1 dev eno2 

After completing this step, you can access the Internet, but the startup and restart will fail
After completing this step, you can access the Internet, but the startup and restart will fail
After completing this step, you can access the Internet, but the startup and restart will fail

[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (220.181.38.149) 56(84) bytes of data.
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=1 ttl=53 time=36.5 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=2 ttl=53 time=37.3 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=3 ttl=53 time=37.2 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=4 ttl=53 time=37.3 ms

Scheme 2: just configure the Internet gateway in / etc/sysconfig/network: (invalid)

1. Configure gateway

[root@localhost ~]# vim /etc/sysconfig/network 
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.10.1               Internet Gateway

2. Configure external network routing

[root@localhost etc]# vim rc.local
route add default gw 192.168.10.1 dev eno2

Scheme 3: modify network card configuration

1. Modify the configuration:

cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ll
 Total consumption 12
-rw-r--r-- 1 root root 373 9 December 17:47 ifcfg-eno1    Intranet card
-rw-r--r-- 1 root root 415 9 December 17:39 ifcfg-eno2    External network card

1, Intranet card 1 (ifcfg-eno1) configuration

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static       Use static ip
DEFROUTE=no            Set as default route
IPV4_FAILURE_FATAL=no
IPV6INIT=no            Initialize ipv6,It mainly uses the external network card, so it is not used
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eno1
UUID=aa78e804-3f06-43fe-8fb3-36575d6fc1ba  Everyone has a different value
DEVICE=eno1
ONBOOT=yes               
DNS1=192.168.130.1          
HWADDR=2C:EA:7F:C2:B6:EF    Hardware address
GATEWAY=192.168.130.1       Gateway (Baidu said to comment or delete, otherwise the Internet can't be used. Anyway, I didn't comment)
IPADDR=192.168.130.2       own IP address
PREFIX=22                  Corresponding to subnet mask 255.255.252.0

2, Configuration of external network card II (external network ifcfg-eno2)

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV4_ROUTE_METRIC=0     Set the routing priority. The lower the value, the higher the priority       
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eno2
UUID=0cde171b-9393-4026-8e7d-269c15c4af89
DEVICE=eno2
ONBOOT=yes
HWADDR=2C:EA:7F:C2:B6:F0
DNS1=192.168.2.1
IPADDR=192.168.2.252
PREFIX=24
GATEWAY=192.168.2.1
NETMASK=255.255.255.0

3, Connection test (remember to restart the network or server)

1. Check the route status. There is only one default route

[root@localhost network-scripts]# ip route list
default via 192.168.2.1 dev eno2 proto static 

2. Access the Internet

[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (220.181.38.149) 56(84) bytes of data.
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=1 ttl=53 time=35.7 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=2 ttl=53 time=42.5 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=3 ttl=53 time=62.8 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=4 ttl=53 time=73.7 ms

3. Access the Intranet

[root@localhost network-scripts]# ping 192.168.130.2
PING 192.168.130.2 (192.168.130.2) 56(84) bytes of data.
64 bytes from 192.168.130.2: icmp_seq=1 ttl=64 time=0.049 ms
64 bytes from 192.168.130.2: icmp_seq=2 ttl=64 time=0.040 ms
64 bytes from 192.168.130.2: icmp_seq=3 ttl=64 time=0.040 ms

And the server restart is valid
And the server restart is valid
And the server restart is valid

4, Knowledge expansion

route -e   View routing table
ip route list    View default routes

Tags: Linux Operation & Maintenance CentOS TCP/IP

Posted by Mattyspatty on Tue, 21 Sep 2021 02:50:22 +0530