Linux网络设置
时间:2019-11-26 10:55 来源:linux.it.net.cn 作者:IT
查看网卡
ifconfig -a 查询所有的网卡
ifconfig 查询已启动的网卡
启动和关闭ens32网卡
sudo ifconfig ens32 up
sudo ifconfig ens32 down
设置网卡ens32的IP地址和子网掩码
sudo ifconfig ens32 192.168.1.44 netmask 255.255.255.0
设置网关
sudo route add default gw 192.168.1.1
修改DNS
使用vim命令编辑50-cloud-init.yaml文件
vim /etc/netplan/50-cloud-init.yaml
修改成下面的格式(格式一定要对齐)
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens32:
addresses: [192.168.1.47/24]
gateway4: 192.168.1.1
nameservers:
addresses: [114.114.114.114]
version: 2
(责任编辑:IT)
查看网卡 ifconfig -a 查询所有的网卡 ifconfig 查询已启动的网卡 启动和关闭ens32网卡 sudo ifconfig ens32 up sudo ifconfig ens32 down 设置网卡ens32的IP地址和子网掩码 sudo ifconfig ens32 192.168.1.44 netmask 255.255.255.0 设置网关 sudo route add default gw 192.168.1.1 修改DNS 使用vim命令编辑50-cloud-init.yaml文件 vim /etc/netplan/50-cloud-init.yaml 修改成下面的格式(格式一定要对齐) # This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: ens32: addresses: [192.168.1.47/24] gateway4: 192.168.1.1 nameservers: addresses: [114.114.114.114] version: 2 (责任编辑:IT) |