- 允许 IP 转发
# To enable IP packet forwarding please edit /etc/sysctl.conf with your editor of choice and set: # Controls IP packet forwarding net.ipv4.ip_forward = 1 # You can then verify your settings with: /sbin/sysctl -p
- 创建虚拟 IP 地址
cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33:0 # 删除 ONBOOT=YES # 添加 ONPARENT=YES # 目的:父接口启动时才启动。 # ONBOOT=YES 会把父接口启动
- 单网卡多Ip
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens32 UUID=0d6815b3-b400-47cf-a418-df8c914568a0 DEVICE=ens32 ONBOOT=yes IPADDR0=192.168.10.130 NETMASK0=255.255.255.0 GATEWAY0=192.168.10.1 IPADDR1=172.20.10.3 NETMASK1=255.255.255.240 GATEWAY1=172.20.10.1
ip地址设置
ip addr add 172.20.10.5/28 dev enp0s3
默认路由添加
ip route add default via 172.20.10.1
- 关闭ipv6
为内核加载添加选项“ipv6.disable=1”vi /etc/default/grub grub2-mkconfig -o /boot/grub2/grub.cfg
模块加载级别关闭ipv6vi /etc/sysctl.conf net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 sysctl -p
运行时关闭 IPv6
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
sysctl -w net.ipv6.conf.all.disable_ipv6=1 sysctl -w net.ipv6.conf.default.disable_ipv6=1
- 修改运行级别
systemctl set-default multi-user systemctl get-default
- 修改时区
cat /etc/timezone timedatectl list-timezones timedatectl list-timezones | grep -i shanghai timedatectl set-timezone Asia/Shanghai
时间同步
timedatectl set-ntp true
CentOS