linux網路配置檔案模板

2021-10-05 15:48:20 字數 2356 閱讀 5919

mac 檢視  numcl device list

uuid檢視 nmcli con list

/etc/sysconfig/network-scrips/ifcfg-*.*

device="eth2

"               //改為ifconfig中的網路介面

bootproto="none

"     //也可以為 dhcp

自動獲取//也可不要,則為靜態

hwaddr="00:0c:29:f8:5d:08

"   //要與實際的mac對應

nm_controlled="yes"   

onboot="yes"

type="ethernet"

ipaddr=192.168.1.123

netmask=255.255.255.0

gateway=192.168.1.3

dns1=192.168.1.3

/etc/sysconfig/network-scrips/ifcfg-*.*

type="ethernet"

proxy_method="none"

browser_only="no"

bootproto="none"

defroute="yes"

ipv4_failure_fatal="no"

ipv6init="yes"

ipv6_autoconf="yes"

ipv6_defroute="yes"

ipv6_failure_fatal="no"

ipv6_addr_gen_mode="stable-privacy"

name="ens192

"uuid="74448d19-6dc4-4c12-9fbd-d9faa289b6bd

"device="ens192

"onboot="yes"

ipaddr="192.168.1.122

"prefix="24"

gateway="192.168.1.3

"dns1="192.168.1.3

"ipv6_privacy="no"

修改網絡卡名字:

新增紅色字型部分字段: cat /etc/sysconfig/grub
grub_cmdline_linux="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swapnet.ifnames=0 biosdevname=0rhgb quiet"

更新grub 配置:grub2-mkconfig -o /boot/grub2/grub.cfg
修改紅色字型部分為實際mac和需要的名字。

cat /etc/udev/rules.d/70-persistent-net.rules

subsystem=="net", action=="add", drivers=="?*",attr=="00:0c:29:a3:b1:5c", attr=="1", kernel=="eth*", name="eno16"

subsystem=="net", action=="add", drivers=="?*", attr=="00:0c:29:a3:b1:8e", attr=="1", kernel=="eth*", name="eno10"

即可。

vi /etc/netplan/*.yaml

*.yaml:

network:

ethernets:

ens33:

dhcp4: no

dhcp4:yes

addresses: [192.168.1.100

/24]               addresses:

optional:true

gateway4: 192.168.1.1

nameservers:

addresses: [223.5.5.5,223.6.6.6

]

version: 2

linux網路配置檔案

type ethernet bootproto static 設定靜態ip defroute yes ipv4 failure fatal no ipv6init yes ipv6 autoconf yes ipv6 defroute yes ipv6 failure fatal no name e...

Linux下網路配置檔案

etc hosts 這個檔案用於設定主機名與 ip 對映關係,為那些無法通過其它方式 如通過 dns 伺服器 解析的主機名進行解析,它還能夠在沒有 dns 的小型網路中充當主機名解析的角色。不論計算機在什麼型別的網路上,hosts 檔案中都有關於環迴鏈路 127.0.0.1 的主機記錄 localh...

Linux網路配置檔案 centos

centos為例 etc sysconfig network檔案 用於基本的網路配置資訊,包含了控制和網路有關的檔案和守護程序的行為引數,包括主機名 閘道器等 預設 我的cent0s7在為空,fedora24也為空,centos6有networking networking ipv6 hostnam...