`
流落星辰
  • 浏览: 12092 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

linux使用1

阅读更多
[/size]在虚拟机上安装了centos7,刚开始联网连接不上,修改/etc/sysconfig/network-scripts/ifcfg-eth0的onboot=yes,能ping同宿主计算机了,那配置ip吧 , 在这个文件中添加
IPADDR=192.168.180.100  #虚拟机的ip地址
NETMASK=255.255.255.0   #网卡对应的网络掩码
GETEWAY=192.168.180.1   #网   关

看下ip 发现没有ifcofig命令
到 usr/sbin下使用发现是可以用的
配置下 /etc/profile
在里面添加
PATH=$PATH:/sbin
export PATH=$PATH:/sbin
好了 ifconfig命令可以用了
远程调用ssh 发现不能使用
命令rpm -qa |grep ssh 发现里面已经安装了 (正常centos都是安装了的)
service sshd start 启动

现在还不能上网 在本地连接里把共享打开
会看到VMnet8配置了个ip
虚拟机里配置 子网ip 192.168.180.0
           网关 192.168.180.1
          ping www.baidu.com ping不通
错误如下
[root@CentOS5 ~]# ping www.sina.com.cn 
ping: unknown host www.sina.com.cn 
1) 确定设置了域名服务器
没有的话, 建议设置Google的公共DNS服务, 它应该不会出问题的
[cpp] view plaincopyprint?
# cat /etc/resolv.conf 
------------------------------------------------------------------- 
nameserver 8.8.8.8 
nameserver 8.8.4.4 
------------------------------------------------------------------- 
2) 确保路由表正常
[cpp] view plaincopyprint?
[root@CentOS5 ~]# netstat -rn 
Kernel IP routing table 
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.180.1   0.0.0.0         UG        0 0          0 eno0
0.0.0.0         192.168.180.1   0.0.0.0         UG        0 0          0 eno0
192.168.180.0   0.0.0.0         255.255.255.0   U         0 0          0 eno0
如果未设置, 则通过如下方式增加网关:
[cpp] view plaincopyprint?
# route add default gw 192.168.180.1 
3) 确保可用dns解析(这步常忘了)
[cpp] view plaincopyprint?
# grep hosts /etc/nsswitch.conf 
------------------------------------------------------------------- 
hosts:      files dns 
-------------------------------------------------------------------  
注意,上面的配置要加上dns。
以下是dns的配置,备忘。
hosts: dns files
表示只在DNS失效时候才使用/etc/hosts文件

hosts: dns
表示只用DNS解析主机

host: files
表示只用/etc/hosts文件解析主机

hosts: files dns
将使用/etc/hosts文件解析主机,表示如果无法解析主机名将使用DNS。

ok  能访问公网了

linux 图形界面远程连接配置
vi /etc/gdm/custom.conf
加入[xdmcp]
Enable=true
Port=177
设置服务器端的防火墙,允许177端口的访问,添加iptables规格
[root@localhost ~]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m udp -p udp --dport 177 -j ACCEPT

重新启动服务器。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics