# PING Network VLAN (host B to host A)



## dcastellacci (Jan 16, 2022)

//
FreeBSD 13.0-RELEASE-p6



host A
-inet 192.168.8.2 re0 ethernet
-inet 192.168.8.3 re0.1 vlan 1
default Gateway 192.168.8.1





host B
-inet 192.168.8.1 re0 ethernet
default Gateway 192.168.1.1









netstat host A

$ netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            192.168.8.1        UGS         re0
127.0.0.1          link#2             UH          lo0
192.168.8.0/24     link#1             U           re0
192.168.8.2        link#1             UHS         lo0
192.168.8.3        link#3             UHS         lo0


$ ifconfig
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
        ether 1c:83:41:27:f5:b8
        inet 192.168.8.2 netmask 0xffffff00 broadcast 192.168.8.255
        media: Ethernet autoselect (1000baseT <full-duplex,master>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
re0.1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=80003<RXCSUM,TXCSUM,LINKSTATE>
        ether 1c:83:41:27:f5:b8
        inet 192.168.8.3 netmask 0xffffff00 broadcast 192.168.8.255
        groups: vlan
        vlan: 1 vlanproto: 802.1q vlanpcp: 0 parent interface: re0
        media: Ethernet autoselect (1000baseT <full-duplex,master>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>


$ sudo sysctl net | grep fibs
net.fibs: 1
net.add_addr_allfibs: 0


Ping Local 
$ ping 192.168.8.3
PING 192.168.8.3 (192.168.8.3): 56 data bytes
64 bytes from 192.168.8.3: icmp_seq=0 ttl=64 time=0.069 ms
64 bytes from 192.168.8.3: icmp_seq=1 ttl=64 time=0.272 ms
64 bytes from 192.168.8.3: icmp_seq=2 ttl=64 time=0.287 ms










netstat host B

]$ netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            192.168.1.1        UGS       wlan0
127.0.0.1          link#2             UH          lo0
192.168.8.0/24     link#1             U           re0
192.168.8.1        link#1             UHS         lo0


$ ifconfig
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
        ether 00:01:2e:38:2d:50
        inet 192.168.8.1 netmask 0xffffff00 broadcast 192.168.8.255
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>


$ sudo sysctl net | grep fibs
net.fibs: 1
net.add_addr_allfibs: 0





Ping host B to host A
$ ping 192.168.8.2
PING 192.168.8.2 (192.168.8.2): 56 data bytes
64 bytes from 192.168.8.2: icmp_seq=0 ttl=64 time=0.316 ms
64 bytes from 192.168.8.2: icmp_seq=1 ttl=64 time=0.518 ms
64 bytes from 192.168.8.2: icmp_seq=2 ttl=64 time=0.429 ms





Ping host B to host A
$ ping 192.168.8.3
PING 192.168.8.3 (192.168.8.3): 56 data bytes
ping: sendto: Host is down
ping: sendto: Host is down
ping: sendto: Host is down
ping: sendto: Host is down
ping: sendto: Host is down










Bonjour
Je ne comprends pas pourquoi je n'arrive pas à fire un ping sur l'adresse 192.168.8.3 du host B vers le host A 
Si je fais un ping à l'adresse 192.168.8.3 sur le host A le ping fonctionne mais pas depuis le host B
Pouvez-vous me donner une solution à ma difficulté Merci Didier


Hello
I don't understand why I can't ping the address 192.168.8.3 from host B to host A
If I ping 192.168.8.3 on host A the ping works but not from host B
Can you give me a solution to my difficulty Thank you Didier


----------



## D-FENS (Jan 16, 2022)

(I am not an expert on VLAN, so I may be wrong)
I think that you should treat your normal LAN and the VLAN as two separate network segments. In your IP settings your interface `hostA:re0.1` is in the same subnet: 192.168.8.0/24. When you pass data through `hostA:re0.1` it gets tagged with VLAN1 and on the other side `hostB:re0` cannot understand the tagged packets, so it ignores them and vice versa - `hostA:re0.1` cannot understand hostB's packets because they are not tagged.

What you should do is, you need to create another VLAN interface on host B: re0.1 on VLAN 1.
Then you need to set the IP address of re0.1 on both hosts in some different IP subnet, for example hostA:re0.1 = 192.168.9.3/24 and hostB:re0.1 = 192.168.9.1/24.
Because they are on the same subnet, the routing tables should be updated automatically.
Then you should be able to ping 192.168.9.3 from host B and vice versa.

Here is a FreeBSD VLAN tutorial that looks quite well: https://genneko.github.io/playing-with-bsd/networking/freebsd-vlan/


----------



## VladiBG (Jan 16, 2022)

dcastellacci said:


> host B
> -inet 192.168.8.1 re0 ethernet
> default Gateway 192.168.1.1


Wrong gateway

To be able to ping you need both host to be on the same VLAN or need to have VLAN routing via the gateway. Host B interface is on Native VLAN (untagged) so it can't ping VLAN1 address of HostA.
Also when you are using VLAN it's better to use different subnet otherwise you can't route them on the router.





_View: https://www.youtube.com/watch?v=vE5gvbmR8jg_


----------



## D-FENS (Jan 16, 2022)

VladiBG said:


> Wrong gateway


But in this case the gateway is not in play because the two IPs are on the same subnet, right?


----------



## VladiBG (Jan 16, 2022)

In order to talk between different VLANS you need VLAN routing. When you have both untagged and tagged traffic on the same subnet you will need to map those in VRF or make some NAT-to-NAT translation with intermediate subnet. Anyway it's much easy to use different subnets and avoid overlapping subnets on different vlans.

hostA
native VLAN - untagged 192.168.8.1

HostB
native VLAN - untagged 192.168.8.2
VLAN 1 - tagged 192.168.8.3

Vlan1 192.168.8.3 can't talk to 192.168.8.1 because it's tagged traffic and there's no router to route the traffic between them.


----------

