linux 服务器加路由,linux添加路由

linux添加路由

http://baikgd.blog.163.com/blog/static/35402495200972111353827/

服务器ip(eth0)

[root@localhost net]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:0C:29:E3:9A:15

inet addr:172.18.3.205 Bcast:172.18.3.255 Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fee3:9a15/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:4776 errors:0 dropped:0 overruns:0 frame:0

TX packets:3348 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:439384 (429.0 KiB) TX bytes:390425 (381.2 KiB)

Interrupt:11 Base address:0x1400

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:254 errors:0 dropped:0 overruns:0 frame:0

TX packets:254 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:22128 (21.6 KiB) TX bytes:22128 (21.6 KiB)

查看原始路由信息

[root@localhost net]# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

172.18.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0

==========================================================

添加默认网关

[root@localhost net]# route add default gw 172.18.3.50

[root@localhost net]# route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

172.18.3.0 * 255.255.255.0 U 0 0 0 eth0

169.254.0.0 * 255.255.0.0 U 0 0 0 eth0

default 172.18.3.50 0.0.0.0 UG 0 0 0 eth0

=======================================================

添加一个ip(eth0:1)

[root@localhost net]# ifconfig eth0:1 192.168.168.119 netmask 255.255.255.0 up

[root@localhost net]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:0C:29:E3:9A:15

inet addr:172.18.3.205 Bcast:172.18.3.255 Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fee3:9a15/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:5071 errors:0 dropped:0 overruns:0 frame:0

TX packets:3569 errors:0 dropped:0 overrun

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值