The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Scripts / handy tips
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 Creating a gateway / router
Author: Dan 
Date:   15-05-09 00:21

Over the past few days, I've had need to turn my laptop into a gateway. I wanted to record the steps because I keep stumbling over them.

On my laptop:

ath0 -connected to my ISP
em0 - connected to my internal switch
internal network is 10.0.0.0/24

- connect to the publc internet:
** ifconfig ath0 up
** dhclient ath0

- bring up em0, which will act as the gateway in my predefined internal network
** ifconfig em0 10.0.0.1 netmask 255.255.255.0

- create my simple NAT rules for pf
# cat /etc/pf.conf
ext_if="ath0"
int_if="em0"

internal_net="10.0.0.0/24"

nat on $ext_if from $internal_net to any -> ($ext_if)

- load pf
# kldload pf

- enable pf
# pfctl -e
No ALTQ support in kernel
ALTQ related functions disabled
pf enabled

- inoke the rules
# pfctl -f /etc/pf.conf
No ALTQ support in kernel
ALTQ related functions disabled


- enable forwarding
# sysctl net.inet.ip.forwarding=1
net.inet.ip.forwarding: 0 -> 1


On the machines inside this temporary network:

- configure the NIC to be inside the network
** ifconfig ale0 10.0.0.2 netmask 255.255.255.0

- set the default router:
# route add default 10.0.0.1
add net default: gateway 10.0.0.1

- make DNS work
# cat /etc/resolv.conf
search wlfdle.phub.net.cable.rogers.com

--
Webmaster

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org