2012年7月12日 星期四
多個介面的Routing設定
多個介面的路由問題, 雖然不算複雜, 但沒弄清楚還是會碰到一些問題 ...
最近在弄一個系統, 有兩個網路介面, 架構大至如下
Interface1 (global IP) -------------------------( Internet )
Interface2 (10.0.0.10/8) ----------------------(10.0.0.254)---------------(172.19.0.0/24)
|-----------------------(192.168.1.0/24)
把兩個介面都成功帶起來後,
Interface1設成default route, 訪問Internet就沒有什麼問題了.
有一些服務綁定在Interface2上, 存取10.0.0.10/8這個網段也很正常.
但問題來了, 無法存取172跟 192這兩個網段.
簡單點的方法, 為這兩個網段, 分別各設一條Routing Rule就解決了
# route add -net 192.168.1.0 netmask 255.255.255.0 gw 10.0.0.254
# route -net 172.19.0.0 netmask 255.255.255.0 gw 10.0.0.254
但假設10.0.0.254那裡又多連接一個新的網段,
到時又得為這個新的網段加一條Routing Rule.
一定還有其他方法來解決這類的Routing問題.
找了一下資料, 發現Source Routing是個不錯的方法,
也不算複雜, 簡單三行就解決,
不用像上面一樣,每個網段都需要設一條
#echo "200 abc" >> /etc/iproute2/rt_tables
#ip rule add from 10.0.0.0/8 table abc
#ip route add default via 10.0.0.254 table abc
1. 新增一個Routing table, 命名為abc, 200是table id, 不可以重複, 可以201, 202, ... 加上去
2. 新增一條規則, 當Source IP為10.0.0.0/8時, 查看abc table
3. 為abc這個table新增一條default route, 當封包來到abc table時, 就會route到這個gw.
查看一下設定內容是否正常.
#ip rule list
#ip route list table abc
設完後, 只要把服務綁到Interface2, 存取172,192網段完全不需要再另外設定Routing Rule了.
2012年7月9日 星期一
不一樣的感動
昨熬夜看溫網男單決賽, 其實不管是誰輸都會讓很多人難過,
現場觀眾最關心的當然是地主選手Murray.
兩位選手的表現, 都讓我很感動
Murray - 在鄉親前拿下自己生涯的第一個大滿貫冠軍
Federer - 重新找回過去的輝煌, 溫網第七冠, 打破偶像山普拉斯的紀錄
Federer贏了, 對我而言, 雖然不意外, 但還是感到很興奮,
他在不被看好的情況下, 確一路打到決賽, 會下冠軍,
年過30, 受傷後還能重回世界第一, 真的很不簡單!
Murray雖然輸了, 但他的表現還是可圈可點,
只要再多一些經驗, 相信他會有機會拿到大滿貫冠軍的!
Murray在賽後的那段話, 很感興, 很有風度~
可惜我的菜英文, 沒有能力全部抓到, 只好找新聞來看看^^
---
Murray lost the match again Roger Federer but won the hearts of the watching world.
The 6ft 3in giant has walked tall – but after yesterday, he’ll never walk alone either.
There was a barely a dry eye on Centre Court as Murray fought for composure,
clutched that mic and battled on with the courage of a true Braveheart.
“I’m going to try this but it’s not going to be easy,” he said.
Willed on by the crowd, Andy, 25,
paused again then said of his victorious opponent:
“Firstly, I’d like to congratulate Roger.
I was getting asked the other day after I’d won my semi-final,
‘Is this your best chance? You know that Roger’s 30 now’.
He’s not bad for a 30-year-old.
He played a great tournament and showed what fight he still has left in him.
So congratulations, you deserve it.”
If ever there was a display of true British generosity in defeat, this was it.
And every word of it will be remembered for years to come by a public down south who never quite knew how to take Murray.
Here in Scotland, of course, there was never any doubt.
Again, he fought off the flood of tears, looked up and, finally,
the words came as he saluted his mother Judy,
girlfriend Kim Sears and all the rest of Team Murray gazing down on him with such pride.
“I’m going to try and not look at them because I’ll start crying again,” he said.
“But everyone that’s in the corner over there that’s supported me through this tournament. It’s
always tough. We did a great job, so thank you.”
Murray then turned to the fans, whose loyalty was well-earned.
“And last of all to you guys,” he said.
“Everybody always talks about the pressure of playing at Wimbledon, how tough it is.
But it’s not the people watching – they make it so much easier to play.
“The support has been incredible, so thank you.”
Source: http://www.dailyrecord.co.uk
---
2012年7月6日 星期五
編kernel module遇到一些麻煩
因為工作需要,不時會寫一些小kernel module來用
以往只有一個.c檔, abc.c, Makefile就很簡單.
編出來的module自然就是abc.ko
------------------------------------------------------------
#
# Makefile for abc driver
#
obj-m = abc.o
------------------------------------------------------------
不過因這次內容有點多,
就依功能把分成兩個檔案 abc.c, xyz.c
同時也修改一下Makefile
------------------------------------------------------------
#
# Makefile for abc driver
#
obj-m = abc.o
abc-objs += xyz.o
------------------------------------------------------------
順利地把abc.ko編出來,沒有compile error.
也有看到abc.o, xyz.o等也都編出來.
但module load進去後功能並不如預期.
反覆試了幾次, 發現連module insert成功的message也沒印出來.
後來把module檔dump出來一看
# objdump -S abc.ko
發現裡面只有包括xyz.c內容,
abc.o雖然有編出來,但裡面的內容跟xyz.o完全一樣,
來看是abc.c完全沒有被編到....
這時才發現Makefile的寫法一整個就是錯誤.
把Makefile改寫後編出來的module再變正常~
改寫後的Makefile:
------------------------------------------------------------
#
# Makefile for abc driver
#
obj-m = aaa.o
aaa-objs += xyz.o
aaa-objs += abc.o
------------------------------------------------------------
不過這樣編出來的module檔名會是 aaa.ko
難道是有多個.c檔時,module的名字就不可以跟其中某個檔案一下?
改天再來研究看看...
訂閱:
文章 (Atom)