Friday, November 28, 2008

Mikrotik Configured as a Gateway server

The following steps are the basic setup Mikrotik theat are configured for the network simple as a gateway server.

1. the first step is to install Mikrotik RouterOS on a PC or plug Dom.

2. Log in Mikrotik router through the console:
Mikrotik v2.9.7
Login: admin
Password: (empty)

Until this step we have to enter the engine Mikrotik. The default user is admin and without a password, type admin and press the enter key.

3. To change the password default security
[admin@Mikrotik]>password
old password: ******
new password: ******
Retype new password: ******
[admin@Mikrotik]>

4. Changing the name Mikrotik Router, Step on this server name will be changed to "BaseStation"
[admin@Mikrotik]identity system set name="BaseStation"
[admin@BaseStaion]>

5. Viewing interface on the Mikrotik Router
[admin@BaseStation]>interface print
Flages: X - disabled, D - dynamic, R - running
#NAME TYPE RX-RATE TX-RATE MTU
0 R ether1 ether 0 0 1500
1 R ether2 ether 0 0 1500
[admin@BaseStaion]>

6. Giving IP address on the interface Mikrotik. Ether1 For example, we will use to connect to the internet with IP 192.168.0.1 and Ether2 will we use for our local network with IP 172.16.0.1

[admin@BaseStation]>ip address add address=192.168.0.1 netmask=255.255.255.0 interface=ether1
[admin@BaseStation]>ip address add address=172.16.0.1/24 interface=ether2

7. See the IP address configuration, which we already provide
[admin@BaseStation]>ip address print
Flags: X - disableed, I - invalid, D - dynamic
#ADDRESS NETWORK BROADCAST INTERFACE
0 192.168.0.1/24 192.168.0.0 192.168.0.63 ether1
1 172.16.0.1/24 172.16.0.0 172.16.0.255 ether2
[admin@BaseStation]>

8. Provide a default gateway, is assumed to be the gateway to the internet connection 192.168.0.254
[admin@BaseStation]> /ip route add gateway=192.168.0.254

9. View the routing table on Mikrotik routers
[admin@BaseStation]>ip route print
Flages: X - disabled, A - active, D -dynamic, C - connect, S - static, r - rip, b - bgp, o - ispf
#DST-ADDRESS PREFSRC G GATEWAY DISTANCE INTERFACE
0 ADC 172.16.0.0/24 172.16.0.1 ether2
1 ADC 192.168.0.0/24 192.168.0.1 ether1
2 A S 0.0.0.0/0 r 192.168.0.254 ether1
[admin@BaseStaion]>

10. Ping Gateway to the test to ensure the configuration is correct
[admin@BaseStation]>ping 192.168.0.254
192.168.0.254 64 byte ping: ttl=64 time<1>
192.168.0.254 64 byte ping: ttl=64 time<1>
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max=0/0.0/0 ms
[admin@BaseStation]>

11. DNS setup on Mikrotik routers
[admin@BaseStation]>ip dns set primary-dns=192.168.0.10 allow-remoterequests=no
[admin@BaseStation]>ip dns set secondary-dns=192.168.0.11 allow-remoterequests=no

12. Viewing DNS configuration
[admin@BaseStation]>ip dns print
primary-dns: 192.168.0.10
secondary-dns:192.168.0.11
allow-remote-requests: no
cache-size: 2048KiB
cache-max-ttl: 1w
cache-used: 16KiB
[admin@BaseStation]>

13. Test access to the domain, for example, ping a domain name
[admin@BaseStation]> ping yahoo.com
216.109.112.135 64 byte ping: ttl=48 time=250 ms
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max=571/571.0/571 ms
[admin@BaseStation]>

if sucessful reply means DNS settings are correct.

14. Masquerading setup, Mikrotik if we will use as a gateway to the client server computer on the network can connect to the internet we need to be masquerading.
[admin@BaseStation]>ip firewall nat add action=masquerade outinterface=ether1 chain=srcnat
[admin@BaseStation]>

15. View configuration Masquerading
[admin@BaseStation]>ip firewall nat print
Flages: X -disabled, I- invalid, D - Dynamic
0 chain=srcnat out-interface=ether1 action=masquerade
[admin@BaseStation]>

after this step can be done to check the connection from a local network. And if successul it means we have to do the installation Mikrotik Router as a Gateway server. Once connected to the network Mikrotik can use WinBox which can be downloads from the Mikrotik.com or form the server Mikrotik us.

Ex: Ip address server Mikrotik we 192.168.0.1, via a browser open http://192.168.0.1/ and WinBox downloads form there.
if we want the client to get the ip address automatically then we need to set up a DHCP-Server on the Mikrotik. Next Steps:

1. Create IP address Pool
/ip pool add name=dhcp-pool ranges=172.17.0.10-172.16.0.20

2. Add a DHCP Network and gateway which will be distributed to the client in this example network is 172.16.0.0/24 and gateway 172.16.0.1

3. add a DHCP server (in this example is applied to the interface dhcp ether2)
/ip dhcp-server add interface=ether2 address-pool=dhcp-pool

4. See the status of the DHCP server
[admin@BaseStation]>ip dhcp-server print
Flags: X -disabled, I - invalid
#NAME INTERFACE RELAY ADDRESS-POOL LEASE-TIME ADD-ARP
0 X dhcp1 ether2
X marks the DHCP server that has not been to enable the first step

5. Do not Forget made enable a dhcp server
/ip dhcp-server enable 0

and then check back dhcp server, such as step-4, X marks if there is no means have been active.

6. Form the client test
c:\>ping http://www.yahoo.com/

for the bandwidth controller, the system can be simple or queue can mangle
[admin@BaseStation] queue simple>add name=Usercomputer1 interface=ether2 target-address=172.16.0.1/24 max-limit=65536/131072
[admin@BaseStation] queue simple>add name=Usercomputer2 interface=ether2 target-address=172.16.0.2/24 max-limite=65536/131072

No comments: