2011年9月8日 星期四

HOW TO set up a RASPPPoE Server ( for Windows )


This document describes how the free RASPPPoE driver can be used on Windows 2000 and higher as a PPPoE Server, allowing client PPPoE configurations to be tested and traced, and also providing Internet connectivity to the client.
Installation and Configuration
  1. Install the RASPPPoE driver on the Windows system.
  2. Click Start, Settings, Network and Dial-up Connections, Make New Connection
  3. In the Network Connection Wizard, click the "Accept incoming connections" radio button.
  4. Select the LAN Adapter to which your RASPPPoE driver is bound.
  5. Select "Do not allow virtual private connection".
  6. Specify the "Allowed Users" details.
  7. Select the "PPPoE Protocol" Networking Component.
  8. Click Finish.
The Network Connection Wizard will then create a new Connection called "Incoming Connections" in the Network and Dial-up Connections folder. You should now view the Properties of that connection and examine the Properties of the TCP/IP Protocol bound to that connection. This is where you specify the IP address assigned to the connection end-points.
If you have access to registered IP addresses managed by a DHCP Server on your enterprise LAN, you should allow address assignment to be done via DHCP.
If you have no spare registered IP addresses, simply use a private IP address like 172.16.1.1 for the Server end of the connection and 172.16.1.2 for the Client end of the connection. To test the client's access to the Internet, simply run NAT32 Build 1036 or later, binding it to your Internet connection and to your RASPPPoE adapter (private interface).
Router Configuration
If you have a router that uses the PPPoE protocol to connect to the Internet, you need to configure it to connect to the RASPPPoE Server. This is usually done by specifying a usercode and password and then letting the router search for a PPPoE server on the network to which it connects. The usercode and password will of course have to match the values you specified when you configured the RASPPPoE Incoming Connection under Windows.
Once you have connected the router to the server, it will then have Internet access via NAT32, and all private machines connected to the router will be able to access the Internet.
You may have to set the MTU that the router uses to 1472 bytes, but the standard PPPoE MTU of 1492 usually works correctly.
Windows Client Configuration
To connect a Windows machine to the NAT32 RASPPPoE Server, open Control Panel, Network and select the Properties of the RASPPoE Protocol. You may need to set the MTU to 1472 bytes, but the standard PPPoE MTU of 1492 usually works correctly.
Now "dial" the connection by clicking the Shortcut that the RASPPPOE.EXE program will have placed on your Desktop.
The client machine (98/SE/ME/2000/XP) will then have Internet Connectivity via the PPPoE protocol.
To trace network traffic, simply click the NAT32 Trace Icon.
Limitations
Windows 2000 Professional allows only two such connections to be in place simultaneously. Windows 2000 Server (and higher) supports more than two simultaneous RASPPPoE connections.
NAT32 supports up to 8 such connections.

linux-PPPoE-server建立


平台環境:
CentOS-5.4
rp-pppoe-3.5-32.1
ppp-2.4.4-2
一、安裝rpm package
    rpm -qa | grep ppp 命令檢查系統是否安裝rp-pppoe和pppd,如果沒有安裝需先安裝這兩個rpm package
二、修改config
cd /etc/ppp/
1.vim pppoe-server-options //修改驗證方式為chap和增加用戶DNS
    
# PPP options for the PPPoE server 
# LIC: GPL 
#require-pap 
require-chap //修改為chap驗證
login 
lcp-echo-interval 10 
lcp-echo-failure 
ms-dns 172.18.0.6 //增加為client分配的DNS地址
~
2.vim chap-secrets
# Secrets for authentication using CHAP 
# client server secret IP addresses 
chao * chao * //添加client端賬號和密碼
abc * abc * 
####### redhat-config-network will overwrite this part!!! (begin) ########## 
####### redhat-config-network will overwrite this part!!! (end) ############
3.vim options
#lock 
local //修改為允許本地用戶驗證
三、開啟PPPoE服務
/usr/sin/pppoe-server -I eth0 -L 192.168.0.1 -R 192.168.0.2 -N 65534
-I 指定LAN網卡
-L 指定SERVER IP地址
-R 指定分配給Clinet端IP地址的起始地址
-N 指定分配給Clinet端IP地址的個數
-k 使用PPP的kernel mode

然後就可以在Clinet端PPPoE-client進行撥號了。但是還不能上網,上網還需要作以下配置。

四、配置網卡
如果是實現PPPOE撥號上網,還需要配置網卡。
LINUX服務器網絡設置
  雖然也可以在圖形界面中是為網卡設置IP地址,但是真正實現網卡IP地址等信息的準確可靠,還是要在相應的文件中作設置,我們本次要設置兩塊網卡,編輯好的文件內容如下:
  [root@localhost network-scripts]# pwd 
  /etc/sysconfig/network-scripts 
  [root@localhost network-scripts]# more ifcfg-eth0 
  TYPE=Ethernet 
  BOOTPROTO=static 
  IPADDR=0.0.0.0 
  DEVICE=lan 
  HWADDR=00:0C :29:0a:69:89 
  ONBOOT=yes 
  NETMASK=0.0.0.0

  [root@localhost network-scripts]# more ifcfg-eth1 
  TYPE="Ethernet" 
  BOOTPROTO=static 
  IPADDR=10.70.10.11 
  DEVICE=wan 
  HWADDR=00:0C:29:33:69:90 
  ONBOOT=yes 
  NETMASK=255.255.0.0 
  GATEWAY=10.70.0.1
我們重點看一下ifcfg-eth1的配置文件,其中ONBOOT="yes"是必須的,可以保證系統啟動網卡自動連接到網絡上,網關的信息是我們手工添加進出去,保證有網關可以正常的訪問外部網絡,ifcfg-eth0文件中只要保證ONBOOT="yes"就可以了,當然像在routeros中一樣,我們將外網口的名字定義為wan,將內網口的名字定義為lan
五、開啟pppoe轉發功能,實現上網
   當然現在客戶端還不能上網,因為PPPOE服務器還沒有啟用NAT,我們用IPTABLES軟件來實現,寫一個這樣的腳本即可:  echo "1" >> /proc/sys/net/ipv4/ip_forward   iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o wan -j SNAT --to 10.70.10.23


  第一行的作用是啟用IP轉發,第二行是啟動IPTABLES進行NAT轉換,下面是對各個參數的解釋
  -t nat表示進行NAT轉化
  -s 192.168.0.0/24表示源地址為192.168.0.0/24這個網段
  -j SNAT --to 10.70.10.23表示將源地址都轉化成10.70.10.23這個外網地址
同樣的,我們可以對照routeros系統裡NAT的設置來理解這條命令。啟動NAT以後,這台PPPOE服務器就功能完整了,客戶端不僅可以撥通服務器,撥通後還可以上網。

2011年9月5日 星期一

Win7 開啟 telnet and tftp

    今天在win7的命令控制台下想telnet 路由器,竟然提示說沒有telnet這條命令。後來發現其實win7上邊是有telnet這條命令的,不過就是default被關閉了。win7開啟telnet方法如下(其他如開啟TFTP命令使用同樣方法打開): 打開Control Panel,選擇Program下的Turn Windows features on or off,在彈出的對話框中將telnet client打上勾就可以打開telnet了。

2011年8月30日 星期二

Printk 的 log level

printk的訊息優先權定義在linux/kernel.h

節錄在下面:

1 KERN_EMERG
2 KERN_ALET
3 KERN_CRIT
4 KERN_ERR
5 KERN_WARNIN
6 KERN_NOTICE
7 KERN_INFO
8 KERN_DEBUG
printk沒有指定時,預設的訊息優先權為 DEFAULT_MESSAGE_LOGLEVEL為/proc/sys/kernel/printk的第二項



log level 數字越低表示印出的訊息越少




printk 會輸出至cirrular buffer
buffer variable : log_buf
len : LOG_BUF_LEN



/proc/sys/kernel/printk檔案分別定義了
console_loglevel
default_message_loglevel
minimum_console_level
default_console_loglevel
printk的log level( Default message loglevel )要大於 console_loglevel這樣一來字才會印出 來


Man /proc的定義如下

  1. Messages with a higher priority than console_loglevel will be printed to the console.
  2. Messages without an explicit priority will be printed with priority default_message_level.
  3. Minimum_console_loglevel is the minimum (highest) value to which console_loglevel can be set.
  4. default_console_loglevel is the default value for console_loglevel
    例如: echo "8" > /proc/sys/kernel/printk
LDD 上有說我們只關心前兩項,因此只要2大於1所有printk的訊息就印得出來,因此將1的值調到八,這樣就可印出所有message

2011年8月25日 星期四

What's bridge-netfilter?


The bridge-netfilter code enables the following functionality:
  • {Ip,Ip6,Arp}tables can filter bridged IPv4/IPv6/ARP packets, even when encapsulated in an 802.1Q VLAN or PPPoE header. This enables the functionality of a stateful transparent firewall.
  • All filtering, logging and NAT features of the 3 tools can therefore be used on bridged frames.
  • Combined with ebtables, the bridge-nf code therefore makes Linux a very powerful transparent firewall.
  • This enables, f.e., the creation of a transparent masquerading machine (i.e. all local hosts think they are directly connected to the Internet).
  • Letting {ip,ip6,arp}tables see bridged traffic can be disabled or enabled using the appropriate proc entries, located in/proc/sys/net/bridge/:
    • bridge-nf-call-arptables
    • bridge-nf-call-iptables
    • bridge-nf-call-ip6tables
    Also, letting the aforementioned firewall tools see bridged 802.1Q VLAN and PPPoE encapsulated packets can be disabled or enabled with a proc entry in the same directory:
    • bridge-nf-filter-vlan-tagged
    • bridge-nf-filter-pppoe-tagged
  • These proc entries are just regular files. Writing '1' to the file (echo 1 > file) enables the specific functionality, while writing a '0' to the file disables it.

sys/utsname.h 平台型號


DESCRIPTION

The  header shall define the structure utsname which shall include at least the following members:
char  sysname[]  Name of this implementation of the operating system. 
char  nodename[] Name of this node within the communications 
                 network to which this node is attached, if any. 
char  release[]  Current release level of this implementation. 
char  version[]  Current version level of this release. 
char  machine[]  Name of the hardware type on which the system is running. 



Example

#include
#include
int main()
{
                struct utsname buf;
                uname (&buf);
                printf ("sysname: %s\n", buf.sysname);
                printf ("nodename: %s\n", buf.nodename);
                printf ("release: %s\n", buf.release);
                printf ("version: %s\n", buf.version);
                printf ("machine: %s\n", buf.machine);
                printf ("domainname: %s\n", buf.__domainname);
                return 0;
}

2011年8月17日 星期三

Windows 7 如何停用、顯示和清除 DNS Cache

今天電腦一直Domain name一直 mapping到錯誤的ip address ,重複實驗了數次,後來才發先是Win 7 內建DNS cache 搞的鬼 @_@"

原來,Windows 7 預設就有啟用 DNS Cache 的功能,如果你不想要用 Windows 7 內建的這個 DNS Cache 功能,只要把這個  DNS Client 服務給停掉就可以了

暫時的停用  DNS Cache 的功能

net stop dnscache 

清空 DNS Cache

ipconfig /flushdns

How to repair and clone disk with ddrescue

  ddrescue  is a tool that can be used to repair and clone disks on a  Linux system . This includes hard drives, partitions, DVD discs, flas...