2014年10月7日 星期二

Cisco Router NAT設定

 摘錄自Shunze 學園 《分享》Cisco Router NAT設定 

Cisco Router上支援三種NAT對應方式。
  • Static NAT:靜態NAT轉址。直接指定每個內部Private IP其對外Public IP,固定為1對1的方式。
    有著數量足夠多的外部IP才會進行這種1對1的設定方式。
  • Dynamic NAT:動態NAT轉址。訂定一到數個NAT Pool,指定可用來做為NAT轉址所用的Public IP之集合,供給內部Private IP動態轉址使用。
    內部對外部不見得是同一個IP,為輪流派送。
  • PAT(Port Address Translation):埠號地址轉換,Overlapping。多個私有ip對應到一個公有ip,也是我們一般認知的NAT


以下我們以模擬器來實做PAT內對外的多對一轉換設定。


內部環境
10.0.0.0/24
GW 10.0.0.254

外部環境
192.168.10.0/30
GW 192.168.10.2


內部Router設定
CODE
//IP配置
(config)# interface fa 0/0
(config-if)# ip address 10.0.0.254 255.255.255.0
(config-if)# no shutdown
(config-if)# interface fa 0/1
(config-if)# ip address 192.168.10.1 255.255.255.252
(config-if)# no shutdown

//NAT設定
(config)# interface fa 0/0
(config-if)# ip nat inside
(config-if)# interface fa 0/1
(config-if)# ip nat outside
(config-if)# exit

//配置NAT pool,起始IP與結束IP
(config)# ip nat pool NATPool1 192.168.10.1 192.168.10.1 netmask 255.255.255.252

//配置access rule,遮罩格式為wildcard-mask
(config)# access-list 1 permit 10.0.0.0 0.0.0.255

//套用NAT來源端規則
(config)# ip nat inside source list 1 pool NAT Pool1 overload

//設定default route
(config)# ip route 0.0.0.0 0.0.0.0 192.168.10.2


ISP Router設定
CODE
//IP配置
(config)# interface fa 0/0
(config-if)# ip address 192.168.10.2 255.255.255.252
(config-if)# no shutdown
(config-if)# interface eth 0/1/0
(config-if)# ip address 123.0.0.254 255.0.0.0.0
(config-if)# no shutdown


偵錯
CODE
# show ip nat translations
# show ip nat statistics


↑由圖中可看到local端的PC 10.0.0.1連到123.123.123.1是帶192.168.10.1的IP出去。

FortiGate雙WAN設定

摘錄自 Shunze 學園 《分享》FortiGate的雙Wan設定

今天有機會在公司的FortiGate上做了雙WAN設定,
原本以為很簡單,很單純,把ISP提供的IP設定好就好?

結果事情沒有傻蛋想的單純...
Wan2是通了,主要流量也從新的Wan2對外聯絡,
但原本Wan1上設定的虛擬IP全部無法提供服務。




設定的重點在於Wan1與Wan2均要提供服務,
所以distance兩著要設定相同的值。

但又希望主要透過Wan2對外?
所以Wan2的優先權要高於Wan1(數字小優先)。

在這樣的設定下,Wan2就會是內網對外的主要通道,
且Wan1的虛擬IP也可正常運作。


但若把distance做了大小不同數值的調整,
那麼優權先低(數字大的)將永遠取不到連通機會。
即使在政策路由中進行了各種設定也沒用!
(所以Wan1上的服務一直不通...)

Fortigate 雙 WAN (負載平衡)備援之一 (檢測機制)

摘錄自 Shunze 學園 專線連通與否之判斷機制
若兩端間的專線是透過一條直通的網路線來連接,
那麼在防火牆上就可以略過“偵測連通與否”的判斷機制。



因為只要任一端網路線拔除,就會造成防火網介面的unplug狀態,而切換到另一條專線。


但實際上在申裝專線時,都是透過ISP業者的機房來串接,
中間經過了幾個機房?又有多少個節點沒人知道。



其中任何一個節點斷線,也不會造成防火牆介面上的unplug狀態。
在這種狀態下,如何確認專線是否連通?
最簡單也最直覺的,就是ping專線另一端的端點。

因此於此架構下,專線介接的port需開放ping的功能,讓專線的另一端能進行偵測;
而防火牆也要設定偵測機制,以確認專線是否連通。


↑Cyberoam的偵測機制


↑FortiGate的偵測機制

___________________________________________________________________________

3 WAN的FortiGate能否設定成跟Cyberoam一樣?
在上述設定範例中,FortiGate 80C只有兩個WAN,
所以無法透過第三個WAN介面提供內對外的網路存取。

但若有3 WAN的FortiGate防火牆,那麼是否可以跟Cyberoam一樣,
二個WAN做專線failover,剩下的一個WAN設定為內對外的需求?



雖然順子沒有3 WAN的FortiGate可供測試,
不過就邏輯來看,要達成這架構絕對沒有問題!
最主要修改的部分,就是“靜態路由”。

WAN1與WAN2的靜態路由要縮小範圍為192.168.128.0/255.255.252.0。
然後再把預設路由0.0.0.0/0.0.0.0指定給WAN3。

這樣要去192.168.128.0/255.255.252.0網段的封包就會透過WAN1/WAN2來繞接;
而要去其它外網的封包,就會透過預設路由WAN3來傳導。

Fortigate 雙 WAN (負載平衡)備援之一

摘錄自Shunze 學園《分享》雙專線備援之防火牆設定Cyberom&FortiGate
設定目標
以Cyberoam與FortiGate兩種不同廠牌的防火牆透過雙專線之串接,
來達成兩個網段連通之failover機制。
當主要連接線路不通時,能夠自動切換到備援線路,維持兩個網段的連通。



設定的要點在於 “雙專線的權重配置” 與 “專線連通與否” 的偵測。


Cyberoam端
雙專線的failover在Cyberoam上,需透過WAN的主要/備援路由自動切換來達成。
為了能夠判斷專線的連通與否,WAN port需啟用ping讓另一端的防火牆能夠借由ping來偵測連線狀態。


第一步先設定Cyberoam上的G port為WAN及其IP設定。


再來設定Cyberoam上的H port為WAN及IP設定。




因為網段內有其自己原來對外的主要WAN通道port D,
所以除了port D的閘道器類型設為啟動外,G/H Port的閘道器類型就設定為備份;
讓default route能指向port D。




接著透過LAN對WAN的防火牆規則設定,將Cyberoam to FortiGate的網段的規則定義清楚。

↑由於兩端網路內電腦IP要直通,不透過NAT轉換,所要取消套用NAT的選項。

雙專線的優先順序則在規則中的閘道器的部份來定義,
設定為主要透過G Port來連通,H Port為備援。


而LAN對其它預設外網則透過D port連接。

↑內部虛擬IP無法直接對外,所要要勾選NAT的選項。這與專線IP直通有意義上的不同。


↑預設外網則透過D port連通。

設定完後,LAN對WAN可以清楚看到兩筆不同規則。

LAN端到FortiGate端10.36.98.0/24會透過規則A_to_W_Uni經由Port G與H來連通;
而LAN端到其它外網則透過規則A_to_W經由Port D來連通。


FortiGate端
雙專線的failover在ForiGate 80C上,同樣可透過雙WAN的設定來達成。
但由於FortiGate 80C上只有兩個WAN port,將兩個WAN Port拿來做專線fail over後,
FortiGate端就不再有對外連通的port了。
要對外連通,需透過其它防火牆並設定路由導向才能辦到。

首先,先設定FortiGate上WAN1的IP設定。

↑為了能夠判斷專線的連通與否,WAN port需啟用ping讓另一端的Cyberoam能夠借由ping來偵測連通與否。

再來設定FortiGate上WAN2的IP設定。

↑同樣需開啟ping讓另一端的Cyberoam能夠判斷連通與否。



而兩個WAN port的優先權重,則可到路由設定的靜態路由中來設置不同的優先權重來區別。

↑WAN1設定為0,做為主要路由。


↑WAN2設定為100,做為備援路由。



而線路是否連通則可在靜態路由中的“設定”來設定偵測機制。
WAN1的部分透過ping的通訊協定每2秒對專線另一端Cyberoam的G Port IP 192.168.12.33來進行偵測。


WAN2的部分,同樣透過ping來測偵專線另一端Cyberoam的H Port IP 192.168.12.37是否連通。




最後到規則中的防火牆策略來設定LAN對WAN1/WAN2及WAN1/WAN2到LAN的放行規則。

↑由於兩端網路內電腦IP要直通,不透過NAT轉換,所要取消套用NAT的選項。

設定完成後,可在規則中看到LAN對WAN1/WAN2及WAN1/WAN2到LAN共四條規則。



FailOver驗證
雙專線的failover驗證可透過FortiGate路由設定中的即時路由來查看。

在主要專線暢通,雙方都ping的到對方的情況下,
可以看到0.0.0.0/0主要路由是透過WAN1與192.168.12.33來連通。


一旦主要專線出現異常,雙方ping不到的情況發生,
就會主動切換到備援專線,透過WAN2與192.168.12.37來連通。

2014年8月22日 星期五

MAC 加入網域

extracted from  http://blog.pluralsight.com/join-mac-to-windows-domain

How to Join a Mac to a Windows Domain

By 

Tell me if this sounds familiar. You come into work one day and your boss calls you into his office and says he got a new laptop. You arrive at his office door and realize your boss bought a Mac. He wants to be able to access all the company files stored on your Windows domain from his new Mac. Or maybe the scenario is a bit different. Your company decides to create a new department for graphical design and marketing and all the designers use Macs.
So what do you do? Not to worry, you can join a Mac to your Windows domain and today I’m going to show you how it’s done. Let’s walk through joining Snow Leopard to a Windows Server 2008 domain.

Setting Network and User Options on a Mac

Windows domains rely on DNS for Active Directory to work correctly so the first thing we need to do is set a static DNS address on your Mac. We need to use the IP address of your Windows domain controller for this setting. From your dock open System Preferences or click the Apple in the top left corner and choose System Preferences. Now click Network to open your network settings.

Now you should be at your Network settings screen.

 
By default your network adapter is set to DHCP. Depending on the network connection you are going to use you will need to change this setting toManually.
Keep in mind if you are setting a static address on your Mac and you take it to another network you might need to change this setting back to DHCP. I would suggest using the wired or Ethernet connection for your static address and use the wireless for DHCP. In this example I am setting a static address on the Ethernet connection.
My Windows domain controller has an IP address of 192.168.1.172 so I will put this in the DNS section. I’m setting my IP address to 192.168.1.171 for this example. Fill in your IP address, subnet, gateway, and DNS according to your network settings.
 
Click the back button to go back to System Preferences and chooseAccounts


Click the Lock to make changes to these settings. Then click the Join button next to Network Account Server


Now click the Open Directory Utility button

You should now be at the Directory Utility; click the Lock to make changes. Then make sure Active Directory is checked, highlight it, and then click the Pencil to edit this setting.

Here you can enter your domain information and computer ID. For this example the domain is hq.test.us and the computer ID is Mac. The computer ID is the computer name that will show up in Active Directory once the Mac is joined to the domain.

*******Set up Create mobile accounts at login *******
_________________________________________________________________________

If you use a portable computer and can join it to a network account server that lets you have a mobile user account, you get the following benefits:
  • A mobile account provides a home folder on both your computer and a network account server. The two home folders are automatically synchronized whenever you log in when you’re connected to the server’s network.
    The term “portable home directory” refers to the synchronized home folders.
  • The appearance of the desktop and other resources on a portable computer is the same, whether or not you’re connected to the network.
  • You use the same user network name and password when you log in, whether or not you’re connected to the network.
Before you can set up a mobile account, you must join your computer to a network account server that supports mobile accounts.
__________________________________________________________________________



Click the arrow to Show Advanced Options. This gives you 3 extra options you can configure. To keep it simple I usually leave these settings default except for the Administrative section. Click the Administrative button and enter the IP address or the FQDN of your domain controller in the Prefer this domain server section. For this example I used the IP address of my domain controller192.168.1.172. You can also specify groups that are allowed administration privileges.

Now click the Bind button and you will be prompted for credentials. Enter your domain administrator username and password and click OK.
You should see it progress through steps 1-5 as you are authenticated and joined to the domain.

Now you should be joined to the domain and the Bind button changes toUnbind.

Click OK and then click Apply in the Directory Utility window. Then close the Directory Utility. Now you should be back at the Accounts window. Note the green dot and domain name next to Network account server.

Logging In with Windows Credentials on Your Mac

Now you should be able to login to the Mac with your Windows domain credentials. Log off the current user you are logged in with. When you get back to the login screen choose Other.

Now enter your Windows domain credentials.

 
That should get you logged into the computer with your domain credentials. So now what? How do you access the files on the server?
We will need to map drives to the shared folders on the server so you can access the files. From Finder click Go then click Connect to Server. Since Mac uses SMB we need to use this syntax: smb://servername/share then clickConnect.





Note that you will not be prompted for credentials to connect because we are logged in with our domain account. You can also connect to Windows shared folders with the same syntax and a username and password if your Mac is not joined to the domain.

Mac on Windows Domain: Is it Worth it?

Now I bet you’re wondering, is this worth it?
This process is not for the faint of heart and can get tricky depending on your environment. There can be issues with joining Macs to a .local domain and there can also be reverse DNS issues to be aware of. With these things in mind, there are definitely some things to consider before joining your Mac to a Windows domain.
Some may wonder what the benefits of joining s Mac to a Windows domain would bring. It mostly helps with accessing files on your Windows server without authenticating every time. It also helps with user account management and alleviates the need to have separate user accounts on the local Mac computer and on the Windows domain.
In my opinion, if you have a mobile Mac user with a laptop you probably wouldn’t join it to your domain, but would instead authenticate when needed. If you have Mac desktop computers and multiple users logging into them and using them daily, joining them to the domain is probably a better solution. Overall it’s up to you how you want to configure it but hopefully this gives you a good baseline to start with.
What other benefits can you think of for joining a Mac to a Windows domain? What other solutions are there for Windows organizations that use Macs?