Freebsd networking: Difference between revisions

From wikinotes
m (Will moved page Freebsd-networking to Freebsd networking)
 
No edit summary
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Manual Connection =
 
= Documentation =
<blockquote>
{| class="wikitable"
|-
| freebsd handbook: network communication || https://docs.freebsd.org/en/books/handbook/partiv/
|-
|}
</blockquote><!-- Documentation -->
 
= Locations =
<blockquote>
{| class="wikitable"
|-
| <code>/etc/rc.conf</code> || persist network configuration
|-
| <code>/etc/resolv.conf</code> || DNS config
|-
|}
</blockquote><!-- Locations -->
 
= Tools =
<blockquote>
{| class="wikitable"
|-
| [[FreeBSD ifconfig]]
|-
| [[FreeBSD route]]
|-
|}
</blockquote><!-- Tools -->
 
= Usage =
<blockquote>
== Restart Network ==
<blockquote>
<syntaxhighlight lang="">
service netif restart
service routing restart
</syntaxhighlight>
</blockquote><!-- Restart Network -->
</blockquote><!-- Usage -->
 
= Examples =
<blockquote>
== Manual DHCP Connection ==
<blockquote>
<blockquote>
<source lang="bash">
<source lang="bash">
Line 10: Line 55:
</blockquote><!-- Manual Connection -->
</blockquote><!-- Manual Connection -->


= Configuration =
== Static IPV4 ==
<blockquote>
<blockquote>
== Static IP ==
<source lang="bash">
<source lang="bash">
# /etc/rc.conf
# /etc/rc.conf
ifconfig_nfe0="inet 192.168.1.220 netmask 255.255.255.0"
 
defaultrouter="192.168.1.1"
ifconfig_em0="inet 192.168.1.220 netmask 255.255.255.0"
ifconfig_em0_alias0="..."
defaultrouter="192.168.1.1" # 'default' route, if directing traffic between ifaces
gateway="192.168.1.1"        # 'default' gateway, for connecting to internet
</source>
</source>


Line 29: Line 75:
ifconfig em0 inet 192.168.0.254 netmask 255.255.255.0         
ifconfig em0 inet 192.168.0.254 netmask 255.255.255.0         
</source>
</source>
</blockquote><!-- Static IPV4 -->
== Static IPV6 ==
<blockquote>
{{ NOTE |
untested }}
<syntaxhighlight lang="bash">
# /etc/rc.conf


== Dynamic IP ==
ifconfig_em0_ipv6="inet6 2607:f0d0:1002:51::4"  # static ip
ifconfig_em0_alias0="inet6 ..."                  # iface aliases
ipv6_defaultrouter="2607:f0d0:1002:51::4"      # 'default' ipv6 route (if routing packages between ifaces)
ipv6_gateway="2607:f0d0:1002:51::4"            # 'default' ipv6 gateway (connecting to the internet)
</syntaxhighlight>
</blockquote><!-- ipv6 -->
 
== IP Aliases ==
<blockquote>
Assign multiple IP addresses to a network interface.<br>
commonly used for assigning IPs to jails.
 
<syntaxhighlight lang="bash">
# /etc/rc.conf


</blockquote><!-- configuration -->
ifconfig_em0_alias0="192.168.1.221/24"
ifconfig_em0_alias1="192.168.1.222/24"
</syntaxhighlight>
</blockquote><!-- IP Aliases -->
</blockquote><!-- Examples -->

Latest revision as of 05:25, 7 August 2021

Documentation

freebsd handbook: network communication https://docs.freebsd.org/en/books/handbook/partiv/

Locations

/etc/rc.conf persist network configuration
/etc/resolv.conf DNS config

Tools

FreeBSD ifconfig
FreeBSD route

Usage

Restart Network

service netif restart
service routing restart

Examples

Manual DHCP Connection

# Starting a manual network connection from CLI
sudo route add default 192.168.1.1 # Set path to your router
ifconfig                           # find interface you want
ifconfig em0 up                    # set interface 'up'
dhclient em0                       # (equivalent of DHCPCD, requests IP address)

Static IPV4

# /etc/rc.conf

ifconfig_em0="inet 192.168.1.220 netmask 255.255.255.0"
ifconfig_em0_alias0="..."
defaultrouter="192.168.1.1"  # 'default' route, if directing traffic between ifaces
gateway="192.168.1.1"        # 'default' gateway, for connecting to internet
# If you still are not able to get outside the internal
# network, try deleting and re-adding the default router from CLI
route delete default
route add default 192.168.1.1  

# The following should restart your internet connection.
ifconfig em0 inet 192.168.0.254 netmask 255.255.255.0

Static IPV6

NOTE:

untested

# /etc/rc.conf

ifconfig_em0_ipv6="inet6 2607:f0d0:1002:51::4"   # static ip
ifconfig_em0_alias0="inet6 ..."                  # iface aliases
ipv6_defaultrouter="2607:f0d0:1002:51::4"       # 'default' ipv6 route (if routing packages between ifaces)
ipv6_gateway="2607:f0d0:1002:51::4"             # 'default' ipv6 gateway (connecting to the internet)

IP Aliases

Assign multiple IP addresses to a network interface.
commonly used for assigning IPs to jails.

# /etc/rc.conf

ifconfig_em0_alias0="192.168.1.221/24"
ifconfig_em0_alias1="192.168.1.222/24"