在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