单网卡跨网段网关连外网

终端为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

 

posted @   小黑狐狸1001  阅读(343)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示