VM安装Rocky8后的设置

1设置ip地址和网关DNS:

Rocky Linux 8.x默认安装好之后是没有自动开启网络连接的!

vim  /etc/sysconfig/network-scripts/ifcfg-ens160
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=3f14ea8b-18e3-47ad-a81a-c05ba26cbde6
DEVICE=eth0
ONBOOT=yes #开启自动启用网络连接
IPADDR0=10.0.0.200 #设置IP地址
PREFIXO0=24 #设置子网掩码
GATEWAY0=10.0.0.254 #设置网关
DNS1=223.5.5.5 设置DNS

 2重载网络配置并安装network.service服务:

Rocky Linux 8.x默认不支持network.service服务,需要使用yum install network-scripts命令来安装此服务。

nmcli c reload
yum install network-scripts
service network restart 
ping www.baidu.com
ip addr
hostname Rocky

3重命名网卡:

cd /etc/sysconfig/network-scripts/
[root@Rocky network-scripts]# mv ifcfg-ens160 ifcfg-eth0
[root@Rocky network-scripts]# vim ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=3f14ea8b-18e3-47ad-a81a-c05ba26cbde6
DEVICE=eth0
ONBOOT=yes
IPADDR0=10.0.0.200
PREFIXO0=24
GATEWAY0=10.0.0.254
DNS1=223.5.5.5

4grub配置并更新内核参数:

在”GRUB_CMDLINE_LINUX“变量中添加一句”net.ifnames=0 biosdevname=0“

然后运行grub2-mkconfig -o /boot/grub2/grub.cfg #重新生成grub配置并更新内核参数

[tyjs09@Rocky network-scripts]$ vim  /etc/sysconfig/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rl-swap rd.lvm.lv=rl/root rd.lvm.lv=rl/swap rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
[tyjs09@Rocky network-scripts]$ grub2-mkconfig -o /boot/grub2/grub.cfg 

5添加udev的规则并重启系统

ATTR{address}=="00:0c:29:80:44:ce"是网卡的MAC地址,使用ip addr命令可以查看到
[tyjs09@Rocky network-scripts]$ cd /etc/udev/rules.d
[tyjs09@Rocky rules.d]$ ls
69-vdo-start-by-dev.rules  70-persistent-ipoib.rules
[tyjs09@Rocky rules.d]$ vim 70-persistent-net.rules
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="00:0c:29:80:44:ce",ATTR{type}=="1" ,KERNEL=="eth*",NAME="eth0"
[tyjs09@Rocky rules.d]$ shutdown -r now 

 

上一篇:C++表达式求值(利用数据结构栈)


下一篇:下载angular项目报错[ERROR] ionic-app-scripts has unexpectedly closed (exit code 1).