一.ubuntu系统:执行sudo vim /etc/netplan/00-installer-config.yaml:
network:
ethernets:
eno1:
dhcp4: false
addresses:
- 192.168.1.2/24
gateway4: 192.168.1.254
nameservers:
addresses: [61.139.2.69, 223.5.5.5]
network:
ethernets:
eno1:
dhcp4: false
bridges:
br0:
interfaces: [eno1]
addresses:
- 192.168.1.2/24
gateway4: 192.168.1.254
nameservers:
addresses: [61.139.2.69, 223.5.5.5]
version: 2
修改成功后执行sudo netplan apply应用配置即可。
二.centos系统:执行vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
IPADDR="192.168.1.2"
NETMASK="255.255.255.0"
GATEWAY="192.168,1.254"
DNS1="223.5.5.5"
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="ens33"
UUID="81e87b75-88f5-4649-bc44-aa703fe3a0fc"
DEVICE="ens33"
ONBOOT="yes"
下面是配置网卡桥接模式,首先新建桥接设备vim /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0"
ONBOOT="yes"
TYPE="Bridge"
BOOTPROTO="static"
IPADDR="192.168.1.2"
NETMASK="255.255.255.0"
GATEWAY="192.168,1.254"
DNS1="223.5.5.5"
DEFROUTE="yes"
DEVICE="ens33"
ONBOOT="yes"
BOOTROTO="yes"
BRIDGE="br0"
修改成功后执行systemctl restart network重启网络服务即可。
|