双网口实现网口2做WAN口

设备使用的是中嵌科技的网关设备,现在有两个网口,其中网口1用于和我的电脑建立ssh通信,网口2准备接路由器上网。
先看看系统版本:

root@EC2022v:~# cat /proc/version
Linux version 3.6.9-rt21-Emfuture (root@imx) (gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 r44365) ) #130 PREEMPT Sun Mar 4 16:39:28 CST 2018

原来的配置文件内容如下:

root@EC2022v:/etc/config# cat network
#lo port seting
config interface loopback
	option ifname	lo
	option proto	static
	option ipaddr	127.0.0.1
	option netmask	255.0.0.0

#lan port seting
config interface lan
	option ifname	eth0
	option type 	null
	option proto	static
	option ipaddr	192.168.0.249
	option netmask	255.255.255.0

config interface lan1
	option ifname	eth1
	option type 	null
	option proto	static
	option ipaddr	192.168.1.249
	option netmask	255.255.255.0

修改后的配置文件如下:

root@EC2022v:/etc/config# vi network
root@EC2022v:/etc/config# cat network
#lo port seting
config interface loopback
	option ifname	lo
	option proto	static
	option ipaddr	127.0.0.1
	option netmask	255.0.0.0

#lan port seting
config interface lan
	option ifname	eth0
	option type 	null
	option proto	static
	option ipaddr	192.168.0.249
	option netmask	255.255.255.0

config interface lan1
	option ifname	eth1
	option type 	null
	option proto	dhcp

最后就可以欢快的上网了:

root@EC2022v:~#ping www.baidu.com
PING www.baidu.com (180.97.33.107): 56 data bytes
64 bytes from 180.97.33.107: seq=0 ttl=50 time=54.223 ms
64 bytes from 180.97.33.107: seq=1 ttl=50 time=52.394 ms
64 bytes from 180.97.33.107: seq=2 ttl=50 time=52.507 ms
64 bytes from 180.97.33.107: seq=3 ttl=50 time=52.619 ms
64 bytes from 180.97.33.107: seq=4 ttl=50 time=52.472 ms
64 bytes from 180.97.33.107: seq=5 ttl=50 time=52.367 ms
64 bytes from 180.97.33.107: seq=6 ttl=50 time=52.577 ms
64 bytes from 180.97.33.107: seq=7 ttl=50 time=52.509 ms
64 bytes from 180.97.33.107: seq=8 ttl=50 time=52.482 ms
64 bytes from 180.97.33.107: seq=9 ttl=50 time=52.531 ms

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值