Sharing Internet connection between GhostBSD and others OS
Posted: Tue Aug 30, 2016 10:03 am
I'm usually connected to Internet thru my WiFi router.
It happens sometimes I need to test/install some OS on some machine that doesn't have a WiFi adapter at all, in this case I connect the machine to my primary GhostBSD machine:
[ Internet ] <-> [ wifi router ] <-> [ GhostBSD ] <- ethernet cable -> [ other OS ]
Note: You can use a straight 1 to 1 cable if both eth devices support autosensing, this is the case for Gigabit capable eth devices, otherwise you need to use a crossed cable when using older non-autosensing eth devices.
How is shared the connection: by using pf filters.
so, be sure to add the following line in your /etc/rc.conf:
and set up your /etc/pf.conf file as follow:
re0 is the name of my Eth device (yours may be dfferent)
wlan0 is the name of my Wifi device
the wifi network is: 192.168.1.0/24 and the wifi card has an address in that range, say 192.168.1.1
the eth network is: 192.168.2.0/24 and the eth device has an address in that range, say 192.168.2.254
That's all on the GhostBSD machine side.
~~~
On the machine you want to connect thru GhostBSD, the INET address must be manually set to something in eth network range, say 192.168.2.1 and you need to set the gateway to the address of the GhostBSD eth device: 192.168.2.254. in my example.
Also, do do forget to set some DNS, say 8.8.8.8 or 8.8.4.4 (google dns)
It happens sometimes I need to test/install some OS on some machine that doesn't have a WiFi adapter at all, in this case I connect the machine to my primary GhostBSD machine:
[ Internet ] <-> [ wifi router ] <-> [ GhostBSD ] <- ethernet cable -> [ other OS ]
Note: You can use a straight 1 to 1 cable if both eth devices support autosensing, this is the case for Gigabit capable eth devices, otherwise you need to use a crossed cable when using older non-autosensing eth devices.
How is shared the connection: by using pf filters.
so, be sure to add the following line in your /etc/rc.conf:
Code: Select all
pf_enable=yes
Code: Select all
ext_if="wlan0"
int_if="re0"
nat pass on $ext_if from $int_if:network to any -> ($ext_if:0)
# NAT: translate all LAN addresses to the external IP address
#nat on $ext_if from 192.168.2.0/24 to any -> ($ext_if)
pass out quick on $ext_if
pass in quick on $int_if from $int_if:network
wlan0 is the name of my Wifi device
the wifi network is: 192.168.1.0/24 and the wifi card has an address in that range, say 192.168.1.1
the eth network is: 192.168.2.0/24 and the eth device has an address in that range, say 192.168.2.254
That's all on the GhostBSD machine side.
~~~
On the machine you want to connect thru GhostBSD, the INET address must be manually set to something in eth network range, say 192.168.2.1 and you need to set the gateway to the address of the GhostBSD eth device: 192.168.2.254. in my example.
Also, do do forget to set some DNS, say 8.8.8.8 or 8.8.4.4 (google dns)