Linux 复制虚拟机

在visual box直接点击右键复制,注意要重新初始化网卡

修改主机名
hostname   #查看主机名
uname -n   #查看主机名

vi /etc/hostname   #修改ubuntu主机名
vi /etc/sysconfig/network   #修改其它版本linux主机名

vi /etc/hosts   #同时也要修改hosts中的主机名

安装ssh
apt list --installed | grep ssh  #检查是否安装ssh  ubuntu
rpm -qa | grep ssh   #检查是否安装ssh  centos

apt install openssh-server  #安装ssh server
apt install openssh-client  #安装ssh client

systemctl status sshd  #检查ssh服务状态
netstat -antlp | grep sshd  #检查sshd监听端口

修改网卡信息和IP地址(仅适用于centos6,ubuntu不需要)

直接修改IP地址会导致错误: Device eth0 does not seem to be present, 所以要按一下步骤执行:
首先,打开/etc/udev/rules.d/70-persistent-net.rules内容如下面例子所示:

# vi /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8f:89:9
7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:50:bd:1
7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

记录下,eth1网卡的mac地址00:0c:29:50:bd:17
接下来,打开/etc/sysconfig/network-scripts/ifcfg-eth0
vi /etc/sysconfig/network-scripts/ifcfg-eth0
将 DEVICE=”eth0” 改成 DEVICE=”eth1” ,
将 HWADDR=”00:0c:29:8f:89:97” 改成上面的mac地址 HWADDR=”00:0c:29:50:bd:17”
最后,重启网络
service network restart


修改成静态IP地址
# for ubuntu 16.04
sudo nano /etc/network/interfaces

# The "primary" network interface 
auto enp0s3
iface enp0s3 inet dhcp

# 将以上内容修改为:
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.1.171
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameserver 119.29.29.29   #这句一定要有

sudo /etc/init.d/networking restart  #重启network
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_26182553

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值