rhel8配置网络,yum(dnf)源等

配置网络

  • my configuration
TYPE=Ethernet
PROXY_METHOD=nonehost host are identicalare identical
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens160
UUID=4b8ad776-004a-4cf4-af7b-8131e8ebe224
DEVICE=ens160
ONBOOT=yes
IPADDR=192.168.10.10
PREFIX=24
GATEWAY=192.168.10.2
DNS1=192.168.10.2

  • 配置文件参数 转自 https://blog.csdn.net/random_w/article/details/84203014

配置文件名称一般为/etc/sysconfig/network-scripts/ifcfg-文件
https://www.thegeekdiary.com/understanding-the-network-interface-configuration-file-etc-sysconfig-network-scripts-ifcfg-eth/
在Redhat中,系统网络设置的配置文件保存在/etc/sysconfig/network-scripts目录下。ifcfg-eth0代表 第一块网卡的配置信息,ifcfg-eth1代表第二块网卡的配置信息。在启动时,系统通过读取这个配置文件决定某个网卡是否启动和如何配置。

DEVICE={name} #{name}表示网卡对应物理设备的名字,eth0是第一块网卡,双网卡或更多依次为eth1,eth
TYPE=Ethernet #网络类型,Ethernet代表以太网
ONBOOT=yes/no #系统启动引导时是否激活该网络接口,设为yes,即激活此设备
BOOTPROTO=none/static/bootp/dhcp #
设置网卡获得ip地址的方式,可能选项为none,static,bootp,dhcp,分别对应不适用协议,静态指定ip地址,,通过bootp协议获得ip地址,通过dhcp协议获得ip地址。
IPADDR={address} #如果设置网卡获得ip地址的方式为静态指定,{addres}就代表赋给该网卡的ip地址。
NETMASK={mask} #{mask}表示网卡对应的网络掩码,如255.255.255.0,与PREFIX=24表示相同的意思。
PREFIX={num} #与NETMASK的含义相同,num表示子网掩码的位数,范围为0~32,配置时只需要NETMASK或PREFIX之一即可。
NETWORK={address} #{address}表示网卡对应的网络地址,(可以不要)
GATEWAY={address} #{address}默认网关
DNS1=10.1.101.51 #DNS服务配置
BROADCAST={address}  #{address}
对应的子网广播地址,如192.168.0.255(可以不要)
MACADDR={MAC-address} #{MAC-address}表示指定一个MAC地址
USERCTL=yes/no    # 是否允许非root用户控制该设备
HWADDR=50:e5:49:df:b0:8b #
对应的网卡物理地址*

二、单网卡绑定2个IP

方法一:
在/etc/sysconfig/network-scripts目录里面创建一个名为ifcfg-eth0:0的文件,
内容样例为:
DEVICE="eth0:0"
IPADDR="x.x.x.x"
NETMASK="255.255.255.0"
如果需要再多绑定一个IP地址,只需要把文件名和文件内的DEVICE中的eth0:0加一即可。
linux最多可支持255个IP别名。

方法二:
直接在配置文件中添加两个IP

DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR0=172.25.254.37
PREFIX0=24
DEFROUTE=yes
IPADDR1=172.25.37.250
PREFIX1=24
DNS1=172.25.254.250
DOMAIN="ilt.example.com example.com"
IPV6INIT=no
PEERNTP=no

三、配置桥接

  • 首先配置桥接网卡
DEVICE=br0  #网卡名称为br0
NAME="Bridge enp0s25"  #这个名称方便阅读配置文件为真实网卡enp0s25的桥接配置
ONBOOT=yes  #默认激活
BOOTPROTO=none  #获取IP地址的方式为noon
IPADDR=172.25.254.37 #IP地址
PREFIX=24 #掩码位数
DEFROUTE=yes #将接口设置为默认路由
DNS1=172.25.254.250 #DNS服务器
DOMAIN="ilt.example.com example.com" #域名
IPV6INIT=no 
PEERNTP=no
TYPE=Bridge #桥接模式
STP=no
  • 配置物理网卡
DEVICE=enp0s25 
BOOTPROTO=none
BRIDGE=br0
ONBOOT=yes
TYPE=Ethernet
NAME="System enp0s25"

systemctl restart network failed

https://www.golinuxcloud.com/unit-network-service-not-found-rhel-8-linux/

[root@rhel-8 ~]# systemctl restart network
Failed to restart network.service: Unit network.service not found.

You can use "NetworkManager.service" as the default networking service in RHEL 8. Red Hat Enterprise Linux 8 uses the default networking service, NetworkManager, which is a dynamic network control and configuration daemon to keep network devices and connections up and active when they are available.

yum(dnf)源

  • 国内源

    https://developer.aliyun.com/mirror/
    http://mirrors.163.com/

    wget http://mirrors.aliyun.com/repo/Centos-8.repo
    vim Centos-8.repo
    enabled=1 //开启镜像
    
    image.png
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
enabled=1
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
enabled=1
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
enabled=1

yum repolist all //检查是否开启服务包
yum makecache //缓存到本地电脑
  • EPEL 第三方源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

你可能感兴趣的:(rhel8配置网络,yum(dnf)源等)