单网卡跨网段网关连外网
终端为192.168.1.x 网关为192.168.0.1
windows设置dhcp可自动实现联网,255.255.253.0掩码会有机会分配到其他网段,但可以上网
Linux 固定ip地址:
默认为:
ping 192.168.0.1
正解:参考:https://www.cnblogs.com/toops/articles/8098155.html
ip route add default via 192.168.0.1 dev wlan0 onlink
default = 0.0.0.0/0 (from:https://netplan.io/examples/)
永久加路由:参考:https://www.cyberciti.biz/faq/ip-route-add-network-command-for-linux-explained/
Edit config file such as /etc/sysconfig/network-scripts/route-eth0 on a CentOS/RHEL/Fedora Linux for interface eth0 using a text editor such as nano command or vim command:
# vim /etc/sysconfig/network-scripts/route-eth0
Append the following text:172.10.1.0/24 via 10.0.0.100 dev eth0
永久加路由(netplan):参考:https://linuxconfig.org/how-to-add-static-route-with-netplan-on-ubuntu-20-04-focal-fossa-linux
(卡在gateway _gateway处)
永久加路由(/etc/rc.local):
1.在/etc/rc.local里添加方法:例子如下
route add -net 192.168.3.0/24 dev eth0
------------以下为其他尝试-------------
X
√ route add -net 0.0.0.0 dev wlan0
可ping通网关192.168.0.1,但还未能ping通外网
try:route add -net 0.0.0.0/24 gw 192.168.0.1
参考:https://blog.csdn.net/u013920085/article/details/51097602