linux系统添加网卡设备及搭建阿里yum源
- 网卡的使用
[[email protected] cobbler]# nmcli connection add type ethernet con-name eth1 ifname eth1
连接“eth1”(9647a0f6-b44d-4a2d-b420-984e61352c30) 已成功添加。#添加网卡eth1
[[email protected] cobbler]# nmcli connection delete eth1# 删除网卡
成功删除连接 ‘eth1’(9647a0f6-b44d-4a2d-b420-984e61352c30)。
[[email protected] cobbler]# nmcli connection down eth0 #关闭网卡
成功取消**连接 ‘eth0’(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/5)
[[email protected] cobbler]# nmcli connection up eth0 #**网卡
连接已成功**(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)
https://opsx.alibaba.com/mirror?lang=zh-CN #阿里yum源网站
- 搭建阿里yum源,虚拟机要桥接网卡配置网关,ping通外网
[[email protected] yum.repos.d]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 #配置网卡配置文件
TYPE=Ethernet
PROXY_METHOD=none
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=eth0
UUID=87a6296a-71fa-4e21-be37-dc9d2b7c858c
DEVICE=eth0
ONBOOT=yes
IPADDR=176.130.7.12
PREFIX=24
GATEWAY=176.130.7.1 #添加网关
[[email protected] ~]# systemctl restart network #重起网卡服务
[[email protected] ~]# route -n #查看网关
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 176.130.7.1 0.0.0.0 UG 100 0 0 eth0
176.130.7.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[[email protected] ~]# ping qq.com #ping外网qq.com
PING qq.com (59.37.96.63) 56(84) bytes of data.
64 bytes from 59.37.96.63 (59.37.96.63): icmp_seq=1 ttl=55 time=59.6 ms
64 bytes from 59.37.96.63 (59.37.96.63): icmp_seq=2 ttl=55 time=28.4 ms
[[email protected] yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #下载阿里yum源配置文件
- yum 相关命令
[[email protected] ~]# yum clean all#清空 yum 缓存
[[email protected] ~]# yum list#生成缓存列表
[[email protected] yum.repos.d]# yum install -y httpd#安装验证
[[email protected] ~]# yum -y reinstall httpd#强制重装
[[email protected] ~]# yum -y remove http#卸载软件
[[email protected] ~]# yum repolist#列仓库