linux 網路配置

2021-08-07 16:13:07 字數 1745 閱讀 1789

1. 配置ip

修改檔案/etc/sysconfig/network-scripts/ifcfg-eth0,根據自己的網絡卡名相應修改。

type="ethernet"

bootproto="none"

defroute="yes"

ipv4_failure_fatal="no"

ipv6init="yes"

ipv6_autoconf="yes"

ipv6_defroute="yes"

ipv6_failure_fatal="no"

name="enp3s0f0"

uuid="57856715-3bab-4897-b0ae-8550cf36229a"

onboot="yes"

hwaddr="d4:c9:ef:cf:8f:b4"

ipaddr0="10.67.1.176"

prefix0="22"

gateway0="10.67.0.254"

ipv6_peerdns="yes"

ipv6_peerroutes="yes"

2. 修改閘道器位址

修改檔案/etc/sysconfig/network

networking=yes

hostname=bsa34

gateway=10.67.0.254

3. 修改dns

修改檔案/ect/resolv.conf

nameserver 8.8.8.8

nameserver 114.114.114.114

4. 重啟網絡卡

centos 7.0

systemctl restart network

centos 6.5

service network restart

這時應該就可以正常上網了。

但是當我們重啟網絡卡時,發現/ect/resolv.conf中的配置沒有了。

這是因為重啟網絡卡會過載ip配置檔案,導致之前的配置被刷掉。

這時我們就可以在ip配置檔案中配置dns

在上述檔案加上

dns1=192.168.1.1

dns2=114.114.114.114

這樣的話,每次重啟網絡卡,都會把/etc/resolv.conf中的配置刷成ip配置檔案中的配置。

最後ip配置檔案/etc/sysconfig/network-scripts/ifcfg-eth0內容

device=eth0

type=ethernet

uuid=f6f05215-46cd-467a-b1a9-bbb3340a788c

onboot=yes

nm_controlled=yes

bootproto=none

ipaddr=10.67.0.20

prefix=16

gateway=10.67.0.254

defroute=yes

ipv4_failure_fatal=yes

ipv6init=no

name="system eth0"

hwaddr=00:0c:29:da:0a:df

netmask=255.255.252.0

dns1=192.168.1.1

dns2=114.114.114.114

結束!!!

網路 linux網路配置

zlm ubuntu sudo ifconfig eth0 192.168.1.109 netmask 255.255.255.0 broadcast 192.168.1.255 zlm ubuntu sudo route add del default gw 192.168.1.1 新增刪除閘道器...

linux配置 網路配置

ip位址,子網掩碼,閘道器 設定ip位址,子網掩碼並啟用 ifconfig eth0 10.192.77.250 netmask 255.255.255.0 up 注 ip,掩碼,閘道器都設定到 etc sysconfig network scripts ifcfg eth0裡面了。設定多ip 可以...

linux網路管理 Linux網路配置

1.1 linux配置ip位址 1 ifconfig命令臨時配置ip位址 能不能自動獲取ip位址和dns位址,要看有沒有dhcp伺服器 win10上,輸入ipconfig all 會看到是否有dhcp伺服器 ifconfig命令 對此命令更加詳細的解說 傳送門 2 setup工具永久配置ip位址 r...