For Debian Linux
先临时设定ip,然后登陆上去
root@ubuntu:~# ifconfig eth0 10.11.12.2/24
root@raspberrypi:~# vim /etc/network/interfaces
# Please note that this file is written to be used with dhcpcd.
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'.
auto lo
iface lo inet loopback
#auto eth0
#allow-hotplug eth0
#iface eth0 inet manual
auto eth0
iface eth0 inet static
address 10.11.12.19
netmask 255.255.255.0
gateway 10.11.12.13
dns-nameservers 180.76.76.76 223.5.5.5
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
root@raspberrypi:~#
重启网络
root@ubuntu:~# ifdown eth0 && ifup eth0
或者:
root@raspberrypi:~# /etc/init.d/networking restart
[....] Restarting networking (via systemctl): networking.serviceWarning: Unit file of networking.service changed on disk, 'systemctl daemon-reload' recommended.
. ok
root@raspberrypi:~# echo $?
0
测试
root@raspberrypi:~# ping www.baidu.com
PING www.a.shifen.com (115.239.210.27) 56(84) bytes of data.
64 bytes from 115.239.210.27: icmp_seq=1 ttl=57 time=2.76 ms
64 bytes from 115.239.210.27: icmp_seq=2 ttl=57 time=2.78 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 2.761/2.770/2.780/0.053 ms
root@raspberrypi:~#
For Redhat Linux
临时修改网卡IP
ifconfig eth0 172..16.0.5/16 up
添加网关
route add default gw 172.16.0.111
临时修改默认的DNS
vim /etc/resolv.conf
vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=00:0C:29:36:**:**
TYPE=Ethernet
UUID=7eaffa26-ee97-4d23-a333-a84da8341***
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=172.16.0.103
NETMASK=255.255.255.0
GATEWAY=172.16.0.111
DNS1=114.114.114.114
DNS2=8.8.8.8
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com