Ubuntu18LTSnetplan⽹络配置⼀、配置⽹络
1、通过netplan配置⽹络
#配置⽹络
nulige@ubuntu:/etc/netplan$ sudo apt install ifupdown
nulige@ubuntu:/etc/netplan$ cd /etc/netplan
nulige@ubuntu:/etc/netplan$ sudo vi 01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
ens33:
addresses: [192.168.56.11/24]
gateway4: 192.168.56.2
nameservers:
addresses: [192.168.56.2, 8.8.8.8]
dhcp4: no
optional: no
nulige@ubuntu:/etc/netplan$ sudo netplan apply
ubuntu网络配置nulige@ubuntu:/etc/netplan$ ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:2b:1a:b2 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.11/24 brd 192.168.56.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fe2b:1ab2/64 scope link
valid_lft forever preferred_lft forever
2、配置⼀个⽹卡,两个IP地址
nulige@ubuntu:~$ cat /etc/network/interfaces
#sudo apt install ifupdown
auto lo
iface lo inet loopback
auto ens33
iface ens33 inet static
address 192.168.56.11
netmask 255.255.255.0
gateway 192.168.56.2
eg1:重启⽹络服务
sudo /etc/init.d/networking force-reload ==> 重新加载⽹路配置⽂件
sudo /etc/init.d/networking restart
eg2:重新启停以太⽹卡:
sudo ifconfig eth0 down
sudo ifconfig eth0 up

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。