博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux 配置静态IP
阅读量:7062 次
发布时间:2019-06-28

本文共 1678 字,大约阅读时间需要 5 分钟。

ip配置方法是编辑sudo nano  /etc/network/interfaces

树莓派默认配置

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

修改为静态ip的方法

1,老外的方法

sudo vi /etc/network/interfaces

To change to static IP address
cd /etc/networks
sudo nano interfaces

replace the line “iface eth0 inet dhcp” with

iface eth0 inet static
address 192.168.1.4
netmask 255.255.255.0
gateway 192.168.1.1
You should also take a look at the file /etc/resolv.conf
and check it has a nameserver entry (probably pointing at your default gateway) or direct to your ISP name servers.
nameserver 192.168.1.1

2.国内帖子

有些朋友一直在问如果配置网络,就简单写写吧,希望能帮助到大家

1.配置ip地址

编辑sudo nano  /etc/network/interfaces

自动获取ip的配置:

auto eth0  
allow-hotplug eth0    
iface eth0 inet dhcp

手动配置ip:

auto eth0   
iface eth0 inet static        
address 192.168.1.7       
netmask 255.255.255.0        
gateway 192.168.0.254

2.配置DNS

编辑 sudo nano /etc/resolv.conf

domain lan

search lan
nameserver 192.168.1.1
nameserver 192.168.99.100

注:nameserver 后面的ip就是dns服务器,根据自己的运营商情况填吧

电脑与树莓派网线直连

方案1:

on your pc

address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.100
on your pi
/etc/network/interface
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.100
方案2:
Rpi
ip 172.16.1.1
mask 255.255.255.0
gateway 172.16.1.2  //172.16.1.1 works too
ubuntu
ip 172.16.1.21
sub 255.255.255.0
gateway 172.16.1.1 //172.16.1.10 works too
方案3:
That worked too.
Don't set the devices to be gateway for each other. All you need is something like this:
IP address of PC: 192.168.1.1
IP address of Rasperberry Pi: 192.168.1.2
Subnet mask on both: 255.255.255.0
Default gateway on both: 192.168.1.254

转载地址:http://bfnll.baihongyu.com/

你可能感兴趣的文章
jQuery上传插件,文件上传测试用例
查看>>
10.5 搜索的优化版
查看>>
mysql中查询语句中的一个知识点说明
查看>>
直接用postman测试api ,服务器端没提供跨域也可以访问。
查看>>
IE8不能保存cookie,造成response.redirect死循环的原因
查看>>
PHP:第六章——正则表达式的基本概念
查看>>
nginx压缩,缓存
查看>>
运营社群看这篇就够了,微信群门槛设置,用户思维、流量思维与产品思维
查看>>
centos彻底删除文件夹、文件命令
查看>>
软件过程
查看>>
脚本监控2个进程有进程死掉重启进程
查看>>
Mac下开机启动rc.common不生效的问题
查看>>
HQL的select new map ···语法
查看>>
牛逼的 弹出层 layer !!!
查看>>
mysql中OPTIMIZE TABLE的作用
查看>>
nslookup工具的使用方法
查看>>
决策树-过程
查看>>
Android适配底部返回键等虚拟键盘的完美解决方案
查看>>
byte[]数组的正则表达式搜索 z
查看>>
jquery获取表单数据方法$.serializeArray()获取不到disabled的值
查看>>