关于树莓派临时静态IP的设置

1:sudo passwd root

输入两边root密码


2:sudo passwd --unlock root  

解锁root账户


3:  关于xrdp的安装  用于远程桌面连接

如果使用命令  sudo apt-get install xrdp  安装出现错误  

可以先更新一下系统   命令  sudo apt-get update  然后在安装就可以了


debian7系统设置固定IP

Linux下查看网关方法:  
  
1、route -n  
  
2、ip route show  
  
3、traceroute www.prudentwoo.com -s 100 【第一行就是自己的网关】  
  
4、netstat -r  
  
5、more /etc/network/interfaces 【Debian/Ubuntu Linux】  
  
6、more /etc/sysconfig/network-scripts/ifcfg-eth0 【Red Hat Linux】  

//查询现有的动态IP地址以及子网掩码
root@hjwdev:/# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0c:29:74:33:a4  
          inet addr:192.168.1.130  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:183175 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20868 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:34441417 (32.8 MiB)  TX bytes:3770024 (3.5 MiB)

//查询现有的DNS服务器地址      
more /etc/resolv.conf
nameserver 202.106.0.10
nameserver 202.106.196.114

//查询现有的网关地址
root@hjwdev:/# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.2     0.0.0.0         UG    0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

1、设置IP地址、网关
nano /etc/network/interfaces  /etc/network/interfacesbak   #备份原有配置文件
nano /etc/network/interfaces   #编辑网网卡配置文件
auto lo
auto eth0  #开机自动连接网络
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static   #static表示使用固定ip,dhcp表述使用动态ip
address 192.168.1.177   #设置ip地址
netmask 255.255.255.0  #设置子网掩码
gateway 192.168.1.2    #设置网关
ctrl+o   #保存配置
ctrl+x   #退出

2、设置dns
cp  /etc/resolv.conf   /etc/resolv.confbak    #备份原有dns配置文件
nano /etc/resolv.conf   #编辑配置文件
nameserver 202.106.0.10   #设置首选dns
nameserver 202.106.196.114   #设置备用dns
ctrl+o   #保存配置
ctrl+x   #退出

3、重启网络
service networking restart   #重启网络
至此,IP地址、网关、DNS配置完成,现在系统已经可以上网了。

猜你喜欢

转载自blog.51cto.com/hudamao/2126899