Hi!
First of all I have to say that I am a complete-complete newbie in networking, routing and similar things. So maybe my question is invalid or just elementary.
I have two machines, one of which is a VPN (Wireguard) server, let's call it 'server', and another one is a client ('client'). On the client, I have a wg0 tunnel interface and all the outgoing traffic is going through it. But I would like mail-traffic (port 25) to be routed not into VPN server, but into another gateway on the client. How can I do that? Now, the point is not in mail and port 25, it could be any port (say, 22 for ssh), I just want to understand the general principle.
I did a quick research, but I found only answers for Linux distros (with
ifconfig
netstat -rn4
If I understand correctly (I'm a newbie), 0.0.0.0/1 says all the outgoing traffic to go into wg0 interface. And I want a traffic for port 25 to go into default gateway (192.168.1.1).
Sorry for clumsy question...
Thank you in advance.
First of all I have to say that I am a complete-complete newbie in networking, routing and similar things. So maybe my question is invalid or just elementary.
I have two machines, one of which is a VPN (Wireguard) server, let's call it 'server', and another one is a client ('client'). On the client, I have a wg0 tunnel interface and all the outgoing traffic is going through it. But I would like mail-traffic (port 25) to be routed not into VPN server, but into another gateway on the client. How can I do that? Now, the point is not in mail and port 25, it could be any port (say, 22 for ssh), I just want to understand the general principle.
I did a quick research, but I found only answers for Linux distros (with
ip rule), but as I can see, it can't be applied to FreeBSD. Honestly, I'm not even sure what tool should I use for that: is this a routing (route) or a firewall (pf) responsibility? It seems that I should use route, but I can't find a way to route a particular port...ifconfig
Code:
em0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
options=4e524bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,LRO,WOL_MAGIC,VLAN_HWFILTER,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6,HWSTATS,MEXTPG>
ether f0:de:f1:ca:7b:fc
inet 192.168.1.90 netmask 0xffffff00 broadcast 192.168.1.255
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
groups: lo
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
wg0: flags=1008043<UP,BROADCAST,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 1420
options=4080000<LINKSTATE,MEXTPG>
inet 10.66.66.2 netmask 0xffffffff broadcast 10.66.66.2
inet6 fd42:42:42::2 prefixlen 128
groups: tun
nd6 options=101<PERFORMNUD,NO_DAD>
Opened by PID 35172
netstat -rn4
Code:
Routing tables
Internet:
Destination Gateway Flags Netif Expire
0.0.0.0/1 link#3 US wg0
default 192.168.1.1 UGS em0
10.66.66.2 link#2 UH lo0
83.217.222.2 192.168.1.1 UGHS em0
127.0.0.1 link#2 UH lo0
128.0.0.0/1 link#3 US wg0
192.168.1.0/24 link#1 U em0
192.168.1.90 link#2 UHS lo0
If I understand correctly (I'm a newbie), 0.0.0.0/1 says all the outgoing traffic to go into wg0 interface. And I want a traffic for port 25 to go into default gateway (192.168.1.1).
Sorry for clumsy question...
Thank you in advance.