千家信息网

Debian Redhat 标准网卡配置

发表于:2025-01-20 作者:千家信息网编辑
千家信息网最后更新 2025年01月20日,For Debian Linux先临时设定ip,然后登陆上去root@ubuntu:~# ifconfig eth0 10.11.12.2/24root@raspberrypi:~# vim /etc
千家信息网最后更新 2025年01月20日Debian Redhat 标准网卡配置


For Debian Linux

先临时设定ip,然后登陆上去root@ubuntu:~# ifconfig eth0 10.11.12.2/24root@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 loiface lo inet loopback#auto eth0#allow-hotplug eth0#iface eth0 inet manualauto eth0iface eth0 inet staticaddress 10.11.12.19netmask 255.255.255.0gateway 10.11.12.13dns-nameservers 180.76.76.76 223.5.5.5auto wlan0allow-hotplug wlan0iface wlan0 inet manualwpa-conf /etc/wpa_supplicant/wpa_supplicant.confauto wlan1allow-hotplug wlan1iface wlan1 inet manualwpa-conf /etc/wpa_supplicant/wpa_supplicant.confroot@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.comPING 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 ms64 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 1001msrtt min/avg/max/mdev = 2.761/2.770/2.780/0.053 msroot@raspberrypi:~#





For Redhat Linux

临时修改网卡IPifconfig eth0 172..16.0.5/16 up添加网关 route add default gw 172.16.0.111临时修改默认的DNSvim /etc/resolv.confvim /etc/sysconfig/network-scripts/ifcfg-eth2DEVICE=eth2HWADDR=00:0C:29:36:**:**TYPE=EthernetUUID=7eaffa26-ee97-4d23-a333-a84da8341***ONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=staticIPADDR=172.16.0.103NETMASK=255.255.255.0GATEWAY=172.16.0.111DNS1=114.114.114.114DNS2=8.8.8.8


0