Reconfiguration of DEFROUTE and GATEWAY in Linux dual-port configuration

When configuring a machine, it follows the original network port configuration, modifies the name of the network port, and changes all em1 to eth0.

 

mv ifcfg-em1 ifcfg-eth0

mv ifcfg-em2 ifcfg-eth1

 

After the modification, the machine became unstable, often stuck and started incorrectly:

 

 

There are three problems encountered in the process of solving this problem:

 

1. No deletion of backup configuration files

ifcfg-em1_bak ifcfg-em2_bak


ifcfg-em3   ifdown-bnep  ifdown-ppp     ifup-bnep     ifup-plusb   ifup-wireless
ifcfg-em4   ifdown-eth   ifdown-routes  ifup-eth      ifup-post    init.ipv6-global
ifcfg-eth0  ifdown-ippp  ifdown-sit     ifup-ippp     ifup-ppp     net.hotplug
ifcfg-eth1  ifdown-ipv6  ifdown-tunnel  ifup-ipv6     ifup-routes  network-functions
ifcfg-lo    ifdown-isdn  ifup           ifup-isdn     ifup-sit     network-functions-ipv6

 

2. Default routing is configured in both ports, which leads to the failure of the second route creation.

Solution: Delete the default route of the second network port and add a permanent route to the / etc/rc.local file:

[root@jiexi5 sysconfig]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#route add default gw 10.204.250.1 dev eth0
route add -net 10.0.0.0/8 gw 10.204.250.1

https://www.cnblogs.com/ssgeek/p/9220690.html

3. Error in the name of eth1 gateway

 

4. After startup, you can only enter the graphical interface. You want to change it to the command line interface.

Use commands: vi/etc/inittab
id:5:initdefault:   
Change 5 to 3:
id:3:initdefault:  
Then wq is saved and OK is restarted.

https://www.cnblogs.com/wi100sh/p/4201031.html

[root@jiexi5 sysconfig]# cat   /etc/inittab   
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
# 
id:3:initdefault:

 

 

 

The following is the initial configuration of the two ports:

Netport eth0

DEVICE="eth0"
TYPE=Ethernet
UUID=04b70242-2f07-450a-b69d-4b05a9cf911a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=14:18:77:40:CC:EB
IPADDR=192.168.3.37
PREFIX=24
GATEWAY=192.168.3.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"

 

 

Netport eth1

[root@jiexi5 sysconfig]# cd network-scripts/
DEVICE="eth1"
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.204.250.20
PREFIX=24
GATEWAY=10.204.250.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="system eth1"
UUID=06878ed9-2826-4873-87ab-c2355d260671
ONBOOT=yes

 

 

 

GATEWAY=10.204.250.1
DEFROUTE=yes

 

The route command can add dynamic routing, but fails after restart

Detailed explanation of route instructions for linux routing table settings

https://www.cnblogs.com/baiduboy/p/7278715.html

Keywords: PHP network Linux

Added by dmdmitri on Wed, 31 Jul 2019 18:01:39 +0300