1.早期SDK,system v 启动方式修改静态IP方法
一、修改文件:/etc/network/interfaces
#wired or wireless interfaces
#eth1
auto eth1
iface eth1 inet dhcp
#eth0
auto eth0
iface eth0 inet static
address 192.168.2.20
netmask 255.255.255.0
gateway 192.168.2.1
二、立即生效
/etc/init.d/networking restart
2.新SDK,system d 启动方式修改静态IP方法
一、参考文档: 1. Systemd: Setup a static IP Address https://michlstechblog.info/blog/systemd-setup-a-static-ip-address/ 二、设置方法: 1. 打开systemd的网络管理功能: systemctl enable systemd-networkd.service 2. 设置网卡信息(修改如下文件中的IP地址): root@zengjf:/etc/systemd/network# cat 10-static-eth0.network [Match] Name=eth0 [Network] Address=192.168.1.202/24 (/24 这个代表netmask,数字代表前面有多少个1,24代表有24个1,对应的是255.255.255.0) Gateway=192.168.1.1 DNS=8.8.8.8 root@zengjf:/etc/systemd/network#
3.重启服务,立即生效
systemctl restart systemd-networkd.service
3. 临时修改
ifconfig eth0 192.168.2.20 netmask 255.255.255.0 up
4.配置双网卡路由策略: