virtualbox虚拟机centos,ubuntu网络设置

时间:2022-12-23 14:44:03
  1. 设置-》网络-》连接方式:桥接
  2. 2.
[caozq@192 ~]$ cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
**#BOOTPROTO=dhcp**
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=ced08473-ed55-440d-b07b-3839cc0e324c
DEVICE=enp0s3
**IPADDR0=192.168.1.100
PREFIX0=24
GATEWAY0=192.168.1.1
DNS1=192.168.1.1
ONBOOT=yes**

修改hostname
sudo hostnamectl set-hostname

reboot
3. 免密码登录
ssh-keygen -t rsa -P ”
scp ~/.ssh/id_rsa.pub caozq@192.168.1.100:~
cat id_rsa.pub >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
3.设置yum源
cd /etc/yum.repos.d
CentOS-Base.repo CentOS-Base.repo.back
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
mv CentOS7-Base-163.repo CentOS-Base.repo
yum clean all
yum makecache