|
virtualbox两个网卡配置:
1
2
3
4
5
6
7
8
9
| a:host-only 模式:
address 192.168.56.1
netmask 255.255.255.0
不启用dhcp服务。
b:nat 模式:
address 10.0.2.0/24
netmask 255.255.255.0
启用dhcp服务
|
虚拟机的网络配置:
配置完成开始安装Ubuntu操作系统。
安装完成,ubuntu操作系统网络配置:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| auto eth0
iface eth0 inet static
address 192.168.56.3
netmask 255.255.255.0
gateway 192.168.56.1
auto eth1
iface eth1 inet static
address 10.0.2.3
netmask 255.255.255.0
dns-nameservers 8.8.8.8
配置完成后重启系统。
hangtiangazi@ubuntu:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.1 0.0.0.0 UG 0 0 0 eth1
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
默认的gateway :10.0.2.1
若是显示的是:
hangtiangazi@ubuntu:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
|
执行以下命令:
1
2
3
4
5
| hangtiangazi@ubuntu:~$ sudo route del dafault gw 192.168.56.1 eth0
hangtiangazi@ubuntu:~$ sudo route add dafault gw 10.0.2.1 eth1
这里ping baidu.com就通了。
执行 sudo apt-get update -y (这一步很重要,若不执行后面没办法执行下载安装)
|
xshell无法远程连接:
1
2
3
4
5
6
7
8
9
10
11
12
| hangtiangazi@ubuntu:~$ ps aux |grep ssh
root 2045 0.0 0.1 61364 3064 ? Ss 15:18 0:00 /usr/sbin/sshd -D
root 2106 0.0 0.2 121952 4624 ? Ss 15:24 0:00 sshd: hangtiangazi [priv]
hangtia+ 2155 0.0 0.1 121952 2220 ? S 15:24 0:00 sshd: hangtiangazi@pts/0
hangtia+ 2286 0.0 0.0 10464 920 pts/0 S+ 16:16 0:00 grep --color=auto ssh
若没有sshd进程,
cd /etc/init.d/
ls |grep ssh
如有,启动ssh服务 sudo ./ssh start
若没有执行:sudo apt-get install -y openssh-server
sudo ./ssh start
xshell端登陆成功。
|
|
|
|
|
|
|
|