配置一台机器时,沿袭了原有网口配置,修改网口名,把em1全部修改改为eth0
mv ifcfg-em1 ifcfg-eth0
mv ifcfg-em2 ifcfg-eth1
改完以后,机器变得不稳定,经常卡住,启动时报错:
解决这个问题的过程中遇到3个问题:
1、备份的网口配置文件没有删除
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、两个网口都配置了默认路由,导致第二个路由创建失败。
解决办法:删除第二个网口的默认路由,在/etc/rc.local文件中加入一条永久路由:
[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/ gw 10.204.250.1
https://www.cnblogs.com/ssgeek/p/9220690.html
3、eth1网口的名称出错
4、启动后只能进图形界面,想改成命令行界面
使用命令: vi /etc/inittab
id:5:initdefault:
中的5 改成3 即可:
id:3:initdefault:
然后wq保存,重启OK。
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(), init(), and initctl().
#
# Default runlevel. The runlevels used are:
# - halt (Do NOT set initdefault to this)
# - Single user mode
# - Multiuser, without NFS (The same as , if you do not have networking)
# - Full multiuser mode
# - unused
# - X11
# - reboot (Do NOT set initdefault to this)
#
id::initdefault:
以下是两个网口最初的配置:
网口eth0
DEVICE="eth0"
TYPE=Ethernet
UUID=04b70242-2f07-450a-b69d-4b05a9cf911a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=::::CC:EB
IPADDR=192.168.3.37
PREFIX=
GATEWAY=192.168.3.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
网口eth1
[root@jiexi5 sysconfig]# cd network-scripts/
DEVICE="eth1"
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.204.250.20
PREFIX=
GATEWAY=10.204.250.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="system eth1"
UUID=06878ed9---87ab-c2355d260671
ONBOOT=yes
GATEWAY=10.204.250.1
DEFROUTE=yes
route命令可以添加动态路由,但重启后失效